I have the following HTML document:
Тег DIV Text Content
How do I describe the style to get the following?
I have the following HTML document:
Тег DIV Text Content
How do I describe the style to get the following?
Until CSS4 border-corner-shape
property is in danger! and it's not implemented, This can be done by using CSS3 transforms (to keep border
property free for further usage):
HTML:
Text Content
CSS:
.box { width: 200px; height: 35px; line-height: 35px; padding: 0 5px; background-color: #ccc; padding-right: 20px; border: solid 1px black; border-right: 0; position: relative; } .box:after { content: ""; display: block; background-color: #ccc; border: solid 1px black; border-left: 0; width: 35px; height: 35px; position: absolute; z-index: -1; top: -1px; /* pull it up because of 1px border */ right: -17.5px; /* 35px / 2 */ transform: skew(-45deg); -o-transform: skew(-45deg); -moz-transform: skew(-45deg); -webkit-transform: skew(-45deg); }
Here is JSBin Demo.
NOTE: There's another div
in example above has class
attribute of box2
, which implemented without using CSS3 declarations that you might consider using it ;)
Most likely it can be done using the inivisble border trick. There are some "triangle generators" on the web, for example, this one
If I describe a document like this:
Тег DIV Text Content
I get almost what you need, but I do not understand why the text is not in the figure?
Here is the Solution.
The CSS and HTML:
ul { position: relative; overflow: hidden; font: 14px Arial; margin: 0; padding: 0; list-style: none; text-align: center; } ul:before { content: ""; position: absolute; z-index: -1; left: 124px; margin-left: -120px; width: 0; border-left: 0 solid transparent; border-right: 230px solid transparent; border-top: 179px solid #CCCCCC; } li { height: 3.8em; line-height: 3em; position: relative; margin-left: -562px; } li:after, li:before { content: ""; display: block; height: 0.4em; background: #fff; width: 100%; }
- Text Content
You have to use the border-width
property to get your desired output.
Hope this helps.