老师请教一下,遇到一个小问题
.con-but {
width: 1600px;
margin: 0 auto;
}
.con-but .b-top,
.con-but .b-but{
margin: 0;
padding: 0;
}
.b-top .t-img,
.b-top .t-word,
.b-but .b-img,
.b-but .b-word{
float: left;
position: relative;
}
.b-top .t-img img,
.b-but .b-img img{
width: 400px;
height: 300px;
}
.b-top .t-word,
.b-but .b-word{
width: 340px;
height: 260px;
padding: 20px 30px;
background: #85e5e4;
}
.word-horn-right{
width: 0;
height: 0;
border-top: 15px solid transparent;
border-right: 25px solid transparent;
border-bottom: 15px solid transparent;
border-left: 25px solid #85e5e4;
position: absolute;
top: 50%;
}
.word-horn-left{
width: 0;
height: 0;
border-top: 15px solid transparent;
border-right: 25px solid #85e5e4;
border-bottom: 15px solid transparent;
border-left: 25px solid transparent;
position: absolute;
right: 0;
top: 50%;
}
.b-top .t-word h3,
.b-but .b-word h3{
color: white;
font-family: "微软雅黑";
margin-bottom: 20px;
}
.t-word p:nth-child(even),
.b-word p:nth-child(even){
color: white;
font-size: 18px;
line-height: 25px;
margin-bottom: 20px;
}
.t-word p:nth-child(odd),
.b-word p:nth-child(odd){
color: #f9f9f9;
font-size: 14px;
line-height: 25px;
margin-bottom: 40px;
}
.t-word button,
.b-word button{
padding: 10px;
background: black;
color: white;
border: 2px solid #85e5e4;
text-align: center;
}
.t-word-but{
text-align: center;
}
.t-word button:hover,
.b-word button:hover{
background: transparent;
color: black;
border: 2px solid black;
}<div class="con-but"> <div class="b-top"> <div class="t-img"> <div class="word-horn-left"></div> <img src="img/b1.jpg"> </div> <div class="t-word"> <h3>Library-1</h3> <p>There are many variations of passages of Lorem Ipsum available.</p> <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour.</p> <div class="t-word-but"> <button>EXPLORE</button> </div> </div> <div class="t-img"> <div class="word-horn-left"></div> <img src="img/b2.jpg"> </div> <div class="t-word"> <h3>Library-2</h3> <p>There are many variations of passages of Lorem Ipsum available.</p> <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour.</p> <div class="t-word-but"> <button>EXPLORE</button> </div> </div> <div class="clear"></div> </div> <div class="b-but"> <div class="b-word"> <h3>Library-3</h3> <p>There are many variations of passages of Lorem Ipsum available.</p> <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour.</p> <div class="t-word-but"> <button>EXPLORE</button> </div> </div> <div class="b-img"> <div class="word-horn-right"></div> <img src="img/b3.jpg"> </div> <div class="b-word"> <h3>Library-4</h3> <p>There are many variations of passages of Lorem Ipsum available.</p> <p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour.</p> <div class="t-word-but"> <button>EXPLORE</button> </div> </div> <div class="b-img"> <div class="word-horn-right"></div> <img src="img/b4.jpg"> </div> <div class="clear"></div> </div> </div>

这里多出4px边距,但是我尝试给上下盒子限制高度,就出现变形,是为什么呢?
0
收起
正在回答
3回答
你好同学 ,根据上传的代码进行测试 ,按钮溢出 ,影响下面的盒子浮动不过去 :

如下修改:
整体的盒子要设置相对浏览器宽度100%显示

里面有8个内容块 ,每个内容块平分25%宽度 :

另外选择题如下设置:

.t-word p:nth-child(3) 表示选择.t-word中第三个子元素 ,并且这个字元素是p . 如下:
两个p的位置分别是第2, 第3 .

.t-word p:nth-child(1)表示的就是.t-word 下面的第一个位置上面的子元素p ,而结果中第一个子元素是h3 ,所以并不会选择上的 .这里要正确里面使用数字的用法 .
希望解答了你的疑惑 ,祝学习愉快 ,望采纳 .
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程

恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星