html设置两个并列图片间隙,css设置两个并排的div同高

默认情况下,块元素将消耗其父级的全部宽度。这就是他们如何满足他们的设计要求,即垂直堆叠。

然而,这种行为并没有扩展到高度。默认情况下,大多数元素是其content(height: auto)的高度。

因此,请记住这两点:

除非你想要全宽,你需要定义一个块元素的宽度

除非您想要内容高度,否则需要定义元素的高度

具体实现代码如下:

.Contact {

display: flex; /* full width by default */

min-height: 100vh; /* use full height of viewport, at a minimum */

}

.left {

flex: 0 0 60%;

background-color: tomato;

}

.right {

flex: 1;

background-color: pink;

}

body { margin: 0; } /* remove default margins */

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

第二种方法:

.wrapper{

position: relative;

width: 200px;

}

.wrapper:before,

.wrapper:after{

content: "";

display: block;

height: 100%;

width: 40%;

border: 2px solid blue;

position: absolute;

top: 0;

}

.wrapper:before{

left: 0;

background-color: red;

}

.wrapper:after{

right: 0;

background-color: green;

}

.div1, .div2{

width: 40%;

display: inline-block;

position: relative;

z-index: 1;

}

.div1{

margin-right: 20%;

}

Content Content Content Content Content Content Content Content Content
Other
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值