gpt4 book ai didi

javascript - HTML 和 CSS : How to lay out a div tag with width:100% and left:300px

转载 作者:行者123 更新时间:2023-11-30 16:56:21 24 4
gpt4 key购买 nike

我在设置 div 标签的样式时遇到问题。我想要一个从 left:300px 开始并跨越到浏览器屏幕末尾的 div 标签。但是如果我设置 width:100%,div 标签将超出浏览器屏幕。

最佳答案

只要用对了。

div {
position: absolute;
left: 300px;
right: 0;
}

https://jsfiddle.net/v2qq0gyp/1/

您也可以对顶部和底部执行此操作,从而生成整页 div:

div {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}

相对位置:

div {
position: relative;
left: 30%;
right: 0;
margin-right: 30%;
}
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In erat urna, interdum non velit id, fringilla tempus lectus. Integer fermentum est in nisi lobortis aliquet. Sed rutrum purus purus, non fermentum nulla volutpat id. In lacus lacus, condimentum ut sollicitudin id, finibus et sem. Nulla magna elit, sagittis vitae tortor eu, tempor placerat elit. Fusce fringilla quam in erat commodo, eget vehicula tellus eleifend. Donec vitae nisi urna.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In erat urna, interdum non velit id, fringilla tempus lectus. Integer fermentum est in nisi lobortis aliquet. Sed rutrum purus purus, non fermentum nulla volutpat id. In lacus lacus, condimentum ut sollicitudin id, finibus et sem. Nulla magna elit, sagittis vitae tortor eu, tempor placerat elit. Fusce fringilla quam in erat commodo, eget vehicula tellus eleifend. Donec vitae nisi urna.
</div>

关于javascript - HTML 和 CSS : How to lay out a div tag with width:100% and left:300px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29662686/

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