gpt4 book ai didi

html - CSS 收缩元素不会导致跳转到下一行

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

我想缩小红色元素并在正确位置以固定宽度放置蓝色元素。

看例子:http://jsfiddle.net/YUTFc/

<div class="wrapper">
<div class="red">1</div>
<div class="blue">2</div>
</div>

.wrapper{
max-width: 300px;
height: 100px;
margin: 0 auto;
}

.red{
height: 100%;
width: 80%;
background-color: red;
float: left;
}

.blue{
height: 100%;
width: 60px;
background-color: blue;
float: right;
}

并调整窗口大小。

我能做什么?谢谢。

最佳答案

试试这个:

.wrapper {
max-width:300px;
height:100px;
margin:0 auto;
position:relative;
}
.red, .blue {
position:absolute;
top: 0; bottom: 0;
}
.red {
background-color:red;
left:0; right:60px;
}
.blue {
background-color:blue;
width:60px; right:0;
}

Updated Fiddle

关于html - CSS 收缩元素不会导致跳转到下一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16108746/

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