gpt4 book ai didi

html - 如何在图像旁边创建两个三 Angular 形?

转载 作者:太空狗 更新时间:2023-10-29 14:12:40 25 4
gpt4 key购买 nike

如何在图像旁边创建两个三 Angular 形?

正如您在 jsfiddle 中看到的那样,三 Angular 形没有触及图像。我希望他们触摸图像和上面的蓝色条。我试过这篇文章:How can I have an image float next to a centered div?没用。

.content {
width: 960px;
margin: 0 auto;
}

ul.producten {
margin-top: 4%;
list-style-type: none;
}

ul.producten li {
width: 315px;
}

ul.producten li img {
display: inline-block;
width: 295px;
}

.producten_top {
width: 315px;
height: 40px;
background: #3bcdff;
}

.producten_top h1 {
font-size: 30px;
color: #fff;
text-align: center;
padding: 5px 0;
}

.arrow_left {
display: inline-block;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #1c1c1d;
transform: rotate(225deg);
float: left;
}

.arrow_right {
display: inline-block;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #1c1c1d;
transform: rotate(315deg);
float: right;
}
<div class="content">
<ul class="producten">
<li>
<div class="producten_top"><h1>Test</h1></div>
<div class="arrow_left"></div>
<img src="http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244" alt="Plafond lampen">
<div class="arrow_right"></div>
</li>
</ul>
</div>

jsfiddle

它需要是什么:

enter image description here

最佳答案

使用 position: absolute 而不是 display: inline-block 并为三 Angular 形提供 8px 边框而不是 5px 并设置 display: blockmargin: auto 使 img 居中。当然,您需要为父级 (ul.producten li) 设置 position: relative;

.content {
width: 960px;
margin: auto;
}

ul.producten {
margin-top: 4%;
list-style-type: none;
}

ul.producten li {
width: 315px;
position: relative;
}

ul.producten li img {
display: block;
width: 295px;
margin: auto;
}

.producten_top {
width: 315px;
height: 40px;
background: #3bcdff;
}

.producten_top h1 {
font-size: 30px;
color: #fff;
text-align: center;
padding: 5px 0;
}

.arrow_left {
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #1c1c1d;
transform: rotate(225deg);
position: absolute;
left: 0;
top: 39px;
}

.arrow_right {
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #1c1c1d;
transform: rotate(315deg);
position: absolute;
right: 0;
top: 39px;
}
<div class="content">
<ul class="producten">
<li>
<div class="producten_top"><h1>Test</h1></div>
<div class="arrow_left"></div>
<div class="arrow_right"></div>
<img src="http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244" alt="Plafond lampen">
</li>
</ul>
</div>

关于html - 如何在图像旁边创建两个三 Angular 形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36516228/

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