我想制作一个这样的基本结构,但条件是我必须只使用" li"在HTML中并完全使用CSS设计它。结构应该是这样的,我可以适应任何图像。
HTML:
<ul class="basic_chevron_process">
<li>Process 1</li>
<li>Process 2</li>
<li>Process 3</li>
</ul>
答案 0 :(得分:3)
这是一种方法,使用伪元素,它是偏斜的,一个在上半部分,另一个在下半部分。
更新了一个也使用图片的选项,由于object-fit
还没有很好的浏览器支持,所以使用background
/ cover
.basic_chevron_process,
.basic_chevron_process li {
margin: 0;
padding: 0;
}
.basic_chevron_process li {
display: inline-block;
position: relative;
text-align: center;
height: 60px;
line-height: 60px;
padding: 0 10px;
width: 120px;
vertical-align: top;
overflow: hidden
}
.basic_chevron_process li input,
.basic_chevron_process li select {
width: 70%;
}
.basic_chevron_process li:before,
.basic_chevron_process li:after {
content: '';
position: absolute;
top: 0;
left: 6%;
height: 50%;
width: 88%;
background: lightblue;
transform: skewX(30deg);
z-index: -1;
}
.basic_chevron_process li:after {
top: 50%;
transform: skewX(-30deg);
}
.basic_chevron_process li:nth-child(2)::before {
display: none;
}
.basic_chevron_process li:nth-child(2)::after {
left: 0;
top: 0;
height: 100%;
width: 100%;
transform: skewX(0);
background: linear-gradient(60deg, transparent 50%, #fff 50%) no-repeat right top,
linear-gradient(120deg, transparent 50%, #fff 50%) no-repeat right bottom,
linear-gradient(-120deg, transparent 50%, #fff 50%) no-repeat left top,
linear-gradient(-60deg, transparent 50%, #fff 50%) no-repeat left bottom,
url(http://lorempixel.com/300/200/animals/3/) no-repeat center;
background-size: 31px 31px,
31px 31px,
31px 31px,
31px 31px,
cover;
}
<ul class="basic_chevron_process">
<li>
<input type="text" value="TEXT1" id="list2_text" />
</li>
<li>
</li>
<li>
<select>
<option value="1">Option1</option>
<option value="2">Option2</option>
</select>
</li>
</ul>
此处包含img
元素和object-fit
.basic_chevron_process,
.basic_chevron_process li {
margin: 0;
padding: 0;
}
.basic_chevron_process li {
display: inline-block;
position: relative;
text-align: center;
height: 60px;
line-height: 60px;
padding: 0 10px;
width: 120px;
vertical-align: top;
overflow: hidden
}
.basic_chevron_process li input,
.basic_chevron_process li select {
width: 70%;
}
.basic_chevron_process li:before,
.basic_chevron_process li:after {
content: '';
position: absolute;
top: 0;
left: 6%;
height: 50%;
width: 88%;
background: lightblue;
transform: skewX(30deg);
z-index: -1;
}
.basic_chevron_process li:after {
top: 50%;
transform: skewX(-30deg);
}
.basic_chevron_process li:nth-child(2)::before {
display: none;
}
.basic_chevron_process li:nth-child(2)::after {
left: 2%;
top: 0;
height: 100%;
width: 96%;
transform: skewX(0);
z-index: 1;
background: linear-gradient(60deg, transparent 50%, #fff 50%) no-repeat right top,
linear-gradient(120deg, transparent 50%, #fff 50%) no-repeat right bottom,
linear-gradient(-120deg, transparent 50%, #fff 50%) no-repeat left top,
linear-gradient(-60deg, transparent 50%, #fff 50%) no-repeat left bottom;
background-size: 31px 31px,
31px 31px,
31px 31px,
31px 31px;
}
.basic_chevron_process li:nth-child(2) img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
<ul class="basic_chevron_process">
<li>
<input type="text" value="TEXT1" id="list2_text" />
</li>
<li>
<img src="http://lorempixel.com/300/200/animals/3/" alt="">
</li>
<li>
<select>
<option value="1">Option1</option>
<option value="2">Option2</option>
</select>
</li>
</ul>
此处包含img
元素和transform: translate
.basic_chevron_process,
.basic_chevron_process li {
margin: 0;
padding: 0;
}
.basic_chevron_process li {
display: inline-block;
position: relative;
text-align: center;
height: 60px;
line-height: 60px;
padding: 0 10px;
width: 120px;
vertical-align: top;
overflow: hidden
}
.basic_chevron_process li input,
.basic_chevron_process li select {
width: 70%;
}
.basic_chevron_process li:before,
.basic_chevron_process li:after {
content: '';
position: absolute;
top: 0;
left: 6%;
height: 50%;
width: 88%;
background: lightblue;
transform: skewX(30deg);
z-index: -1;
}
.basic_chevron_process li:after {
top: 50%;
transform: skewX(-30deg);
}
.basic_chevron_process li:nth-child(2)::before {
display: none;
}
.basic_chevron_process li:nth-child(2)::after {
left: 0;
top: 0;
height: 100%;
width: 100%;
transform: skewX(0);
z-index: 1;
background: linear-gradient(60deg, transparent 50%, #fff 50%) no-repeat right top,
linear-gradient(120deg, transparent 50%, #fff 50%) no-repeat right bottom,
linear-gradient(-120deg, transparent 50%, #fff 50%) no-repeat left top,
linear-gradient(-60deg, transparent 50%, #fff 50%) no-repeat left bottom;
background-size: 31px 31px,
31px 31px,
31px 31px,
31px 31px;
}
.basic_chevron_process li:nth-child(2) img {
position: absolute;
top: 50%;
left: 50%;
width: auto;
height: auto;
min-height: 100%;
min-width: 100%;
transform: translate(-50%, -50%);
}
<ul class="basic_chevron_process">
<li>
<input type="text" value="TEXT1" id="list2_text" />
</li>
<li>
<img src="http://lorempixel.com/300/200/animals/3/" alt="">
</li>
<li>
<select>
<option value="1">Option1</option>
<option value="2">Option2</option>
</select>
</li>
</ul>