我应该如何将此对象从 .PSD 转换为 HTML/CSS?
How should I convert this object from .PSD to HTML/CSS?
如果可能的话,我应该用纯 CSS 制作这个对象,还是将其用作 div 的背景图像?
它超出了主要内容区域,所以我不确定如何实现它。我想我应该对 div?
使用绝对定位
CSS 仅 解决方案使用 border
:
.block {
background-color: #f3f3f3;
color: #909090;
font-family: Arial, sans-serif;
margin: 0 auto;
padding: 20px 20px 10px;
width: 300px;
}
.block h2 {
background-color: #a9c4c6;
color: white;
font-family: Roboto Slab, serif;
font-weight: normal;
position: relative;
left: -29px;
margin: 0;
position: relative;
text-indent: 29px;
text-transform: uppercase;
}
.block h2:before {
content: "";
display: block;
position: absolute;
top: -8px;
left: 0;
border-width: 4px 5px;
border-color: #84a0a2;
border-style: solid;
border-top-color: transparent;
border-left-color: transparent;
width: 0;
height: 0;
}
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
<section class="block">
<h2>Furniture</h2>
<p>Should I make this object from pure CSS if it is possible or us it as a background image for a div?</p>
<p>It goes outside of main content area so I am not sure how to implement it. I guess I should use absolute positioning for the div?</p>
</section>
我们必须使用 css 边框,我们得到相同的....
要了解更多信息,您必须像这篇文章一样阅读如何使用 css 形状 https://css-tricks.com/examples/ShapesOfCSS/。
.main{
padding:20px;
}
.test {
font-size: 15px;
background: #ccc;
padding:10px
}
h2
{
position: relative;
width: 50%;
font-size: 1.5em;
font-weight: bold;
padding: 6px 20px 6px 70px;
color: #555;
background-color: #AECACC;
text-shadow: 0px 1px 2px #bbb;
-webkit-box-shadow: 0px 2px 4px #888;
-moz-box-shadow: 0px 2px 4px #888;
box-shadow: 0px 2px 4px #888;
left:-20px;
}
h2:after
{
content: ' ';
position: absolute;
/*EDIT border WIDTH as you want fold tringle with css */
border-bottom: 10px solid #8BA8AA;
border-left: 10px solid transparent;
height: 0;
width: 0;
left: 0px;
/*EDIT TOP as border width */
top: -10px;
}
<div class="main">
<div class="test">
<h2>HEADING HERE</h2>
</div>
</div>
如果可能的话,我应该用纯 CSS 制作这个对象,还是将其用作 div 的背景图像?
它超出了主要内容区域,所以我不确定如何实现它。我想我应该对 div?
使用绝对定位CSS 仅 解决方案使用 border
:
.block {
background-color: #f3f3f3;
color: #909090;
font-family: Arial, sans-serif;
margin: 0 auto;
padding: 20px 20px 10px;
width: 300px;
}
.block h2 {
background-color: #a9c4c6;
color: white;
font-family: Roboto Slab, serif;
font-weight: normal;
position: relative;
left: -29px;
margin: 0;
position: relative;
text-indent: 29px;
text-transform: uppercase;
}
.block h2:before {
content: "";
display: block;
position: absolute;
top: -8px;
left: 0;
border-width: 4px 5px;
border-color: #84a0a2;
border-style: solid;
border-top-color: transparent;
border-left-color: transparent;
width: 0;
height: 0;
}
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
<section class="block">
<h2>Furniture</h2>
<p>Should I make this object from pure CSS if it is possible or us it as a background image for a div?</p>
<p>It goes outside of main content area so I am not sure how to implement it. I guess I should use absolute positioning for the div?</p>
</section>
我们必须使用 css 边框,我们得到相同的....
要了解更多信息,您必须像这篇文章一样阅读如何使用 css 形状 https://css-tricks.com/examples/ShapesOfCSS/。
.main{
padding:20px;
}
.test {
font-size: 15px;
background: #ccc;
padding:10px
}
h2
{
position: relative;
width: 50%;
font-size: 1.5em;
font-weight: bold;
padding: 6px 20px 6px 70px;
color: #555;
background-color: #AECACC;
text-shadow: 0px 1px 2px #bbb;
-webkit-box-shadow: 0px 2px 4px #888;
-moz-box-shadow: 0px 2px 4px #888;
box-shadow: 0px 2px 4px #888;
left:-20px;
}
h2:after
{
content: ' ';
position: absolute;
/*EDIT border WIDTH as you want fold tringle with css */
border-bottom: 10px solid #8BA8AA;
border-left: 10px solid transparent;
height: 0;
width: 0;
left: 0px;
/*EDIT TOP as border width */
top: -10px;
}
<div class="main">
<div class="test">
<h2>HEADING HERE</h2>
</div>
</div>