我在下面创建了以下横幅,使用三角形和矩形为了在图像上创建所需横幅。但是,如果用户在浏览器中放大这两个容器之间的差距。任何想法如何我可以将两个容器固定在一起,或者有更好的方法来使用CSS编写此横幅广告?提前致谢! :)修复浏览器上的容器缩放和调整大小
代码:
<html>
<style>
#triangle {
width: 0;
height: 0;
border-bottom: 150px solid red;
border-right: 50px solid transparent;
top: 8px;
position: relative;
}
#square {
background-color:red;
height:150px;
width:300px;
z-index: 3;
margin-left: 8px;
top: 8px;
position: relative;
color: white;
}
.align div {
display:inline-block;
float: left;
}
</style>
<div class="img">
<img src="IMAGE HERE" alt="test" width="800" height="150">
</div>
<div class="align">
<div id="square">
<h1>
Headline
</h1>
<p>
Some text here!
</p>
</div>
<div id="triangle"></div>
</div>
</html>
你的html在哪里? –
对不起,我的错误。 HTML添加:) – Andrew
用JSFiddle查看代码时我看不到任何差距 – Relisora