gpt4 book ai didi

css - 960 像素以下的内容框 - 窗口外

转载 作者:太空宇宙 更新时间:2023-11-04 06:06:57 25 4
gpt4 key购买 nike

我的内容框(白框)宽度减小到 960 像素以下,文本从右侧窗口中移出。我试图找出使用检查器的方法,但在我看来,一切都按应有的方式定义。我不知道我做错了什么。

HTML 和 CSS 一起:

https://codepen.io/drol/pen/RmLaZN

#slika {
height:70vh;
width:100vw;
background-color:#df1f26;
object-fit: cover;
overflow:hidden;
}

.imagetop {
height:auto;
width:100vw;
float: left;
object-fit: cover;
}

#crveni {
position:relative;
height:auto;
width:100vw;
background-color:#df1f26;
padding-bottom:80px;
}

#sadrzaj {
position:relative;
top:-80px;
left:20vw;
width:510px;
padding:35px;
background-color:white;
line-height:180% !important;

}

@media (max-width:960px) {
h1 {
color:#df1f26;
}
#sadrzaj {
top:0px;
left:0px;
bottom:0px;
right:0px;
width:100vw;
}
#crveni {
padding-bottom:0px;
position: absolute;
}
#slika {
height:auto;
}
.imagetop {
height:auto;
width:100vw;
object-fit: cover;
}
}
<div id="slika"><img src="https://cdn.mos.cms.futurecdn.net/FUE7XiFApEqWZQ85wYcAfM-970-80.jpg" alt="" class="imagetop"></div>
<div id="crveni"><div id="sadrzaj"><h1>Main title</h1><h3>Subtitle of this post. Subtitle of this post. Subtitle of this post. Subtitle of this post. </h3><br/><p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus convallis nulla in ornare porttitor. Nam molestie dolor euismod commodo laoreet. Nam malesuada orci ac volutpat pretium. Nam lectus ante, facilisis ac urna eget, cursus semper nisl. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tellus orci, rutrum id auctor vel, convallis et lacus. Vestibulum luctus tincidunt purus pretium cursus. Vestibulum justo erat.</div></div>

最佳答案

问题是 border-box属性未在您的 CSS 中定义。

所以,内容溢出了body由于width: 100vwpadding: 35px;计算为总宽度。

#sadrzaj {
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
width: 100vw;
box-sizing: border-box; //added box-sizing
}

Solved JSFiddle link

Read more about box-sizing

关于css - 960 像素以下的内容框 - 窗口外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56773183/

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