我试图创建标头与倾斜的边缘,保持其纵横比无论他们出现什么样的高度。这是可能完成使用CSS单独?DIV与倾斜的边缘,保持长宽比
此图像显示了头的样子,如果他们只有一条线长:
,如果他们两个或更多的线长,他们应该出现像:
我正在运行的问题是我无法使白色半边三角形覆盖标题的右侧部分来调整大小,更不用说调整其相同宽高比。下面是多线会发生什么原样:
现在显示标题的代码是:
HTML:
<header>
<nav>
<ul>
<li><a href="#">Public Information</a></li>
</ul>
</nav>
<h1>Board Meeting Schedule</h1>
</header>
CSS:
* {
font-family: sans-serif;
font-size: 16px;
font-weight: normal;
line-height: normal;
margin: 0;
}
header {
background: #0D3C5B;
display: inline-block;
overflow: hidden;
padding: 18px 80px 12px 20px;
position: relative;
}
header:before {
border-left: 58px solid transparent;
border-top: 62px solid #FFF;
content: "\0020";
display: block;
height: 0;
position: absolute;
right: 0;
top: 0;
width: 0;
}
header nav {
float: left;
margin: 0 6px 0 0;
}
header nav ul {
color: #42AFE3;
display: inline-block;
font-size: 0.75em;
font-weight: bold;
line-height: 1.6666666666666666666666666666667em;
line-height: 2.25em;
list-style: normal;
margin: 0;
padding: 0;
text-transform: uppercase;
}
header nav ul li {
display: inline-block;
}
header nav ul li a {
color: #42AFE3;
text-decoration: none;
}
header nav ul li:after {
content: "\003E";
padding: 0 4px;
}
header h1 {
color: #FFF;
float: left;
font-size: 1.25em;
font-weight: bold;
line-height: 1em;
text-transform: uppercase;
}
header:after {
clear: both;
content: "\0020";
display: block;
visibility: hidden;
}
这里是一个小提琴:http://jsfiddle.net/doLuj6me/
我宁愿通过使用背景图像来解决它 –
我不会,因为背景图像不能很好地缩放。我总是喜欢尽可能使用CSS。 – JacobTheDev