gpt4 book ai didi

html - 正确使用 margin 属性将 Logo 定位到右侧

转载 作者:太空宇宙 更新时间:2023-11-03 23:02:05 24 4
gpt4 key购买 nike

有html

<div class="wrapper" id="top">
<div class="main-logo bg-yellow-niza">
<img src="http://eurekavi.com/car/images/logo.png" alt=""></div>
</div>

和CSS

.wrapper {
width: 100%;
margin: 0 auto;
}

.main-logo {
background: #707070;
height: 100px;
width: 100px;
margin: 0 auto;
left: 0;
right: 0;
position: absolute;
z-index: 9999;
}

.main-logo img {
text-align: right;
margin: 0 auto;
margin-top: 0;
width: 100%;
}

它在屏幕中央正确显示 Logo ,但我想将其定位在右上角之前 200 像素处。

enter image description here

我试过修改 left: 0;和 right: 0; 值,但我无法在右外 Angular 之前找到 Logo 。

怎么做?

请看jsfiddle

最佳答案

改变这个:

.main-logo {
background: #707070;
height: 100px;
width: 100px;
margin: 0 auto;
left: 0;
right: 0;
position: absolute;
z-index: 9999;
}

为此:

.main-logo {
background: #707070;
height: 100px;
width: 100px;
right: 200px;
position: absolute;
z-index: 9999;
}

不同之处在于将“右”位置设置为 200 像素,删除“左:0;”并去除边距。

关于html - 正确使用 margin 属性将 Logo 定位到右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36122011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com