gpt4 book ai didi

html - 依次放置几个div width full width 并调整图像背景的宽度和高度

转载 作者:行者123 更新时间:2023-11-28 15:05:01 26 4
gpt4 key购买 nike

我想依次显示 div #botone#bottwo#bottree。我还希望在 #botone div 上按 100% 宽度和比例高度调整背景图像。

现在最后两个 Div 显示在 #botone Div 后面,#botone div 将 49px 添加到来自 .topnav 的垂直位置 分区

我还想将 .topnav Div 固定在顶部。

** body {
margin: 0px 0px;
}


/* Add a black background color to the top navigation */

.topnav {
background-color: #000;
overflow: hidden;
height: 49px;
}


/* Style the links inside the navigation bar */

.topnav a {
float: right;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}


/* Change the color of links on hover */

.topnav a:hover {
background-color: #ddd;
color: black;
}


/* Add a color to the active/current link */

.topnav a.active {
background-color: #4CAF50;
color: white;
}

.block {
float: left;
width: 40px;
}

.blocka {
float: right;
width: 250px;
}

#botone {
position: absolute;
height: 100%;
width: 100%;
background-image: url("arc.jpg");
background-size: cover;
}

#bottwo {
background-color: blue;
height: 400px;
width: 100%;
}

#botthree {
background-color: yellow;
height: 600px;
width: 100%;
}
<div class="topnav">
<div class="block">
<a href="#oi">Oi</a>
</div>
<div class="blocka">
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
</div>
<div id="botone">testtext
</div>
<div id="bottwo">testtext
</div>
<div id="botthree">testtext
</div>

最佳答案

如果我正确理解您的问题,这是否可以实现您的目标?

HTML:

<div class="topnav">
<div class="block">
<a href="#oi">Oi</a>
</div>
<div class="blocka">
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
</div>
<div id="botone">testtext
</div>
<div id="bottwo">testtext
</div>
<div id="botthree">testtext
</div>

CSS:(底部的变化)

body {
margin: 0px 0px;
}

/* Add a black background color to the top navigation */
.topnav {
background-color: #000;
overflow: hidden;
height: 49px;

}

/* Style the links inside the navigation bar */
.topnav a {
float: right;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}

/* Add a color to the active/current link */
.topnav a.active {
background-color: #4CAF50;
color:white;
}

.block { float:left;width: 40px; }
.blocka { float:right;width: 250px; }

#botone {
position: absolute;
height: 100%;
width: 100%;
background-image: url("arc.jpg");
background-size: cover;
}
#bottwo {
background-color:blue;
height: 400px;
width: 100%;

}
#botthree {
background-color:yellow;
height: 600px;
width: 100%;
}


/*--- Fixes --*/

.topnav {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 5;
}

#botone {
/*-- Test --*/
background-image: url("https://images.pexels.com/photos/948358/pexels-photo-948358.jpeg?auto=compress&cs=tinysrgb&h=650&w=940");

background-position: center;
height: 100vh;
margin-top: 49px;
position: relative;
}

link to example

关于html - 依次放置几个div width full width 并调整图像背景的宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49576586/

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