css3 outline attribute

巴扎黑
Release: 2017-06-28 13:55:14
Original
2037 people have browsed it

When I was reading articles related to CSS3, I saw a way to use CSS styles to achieve a "+" plus sign effect

Here I came into contact with a new CSS3 attribute, outline, which translated into Chinese is——"outline ";

Syntax: outline:outlineWidth outlineStyle outlineColor;

For example: outline:5px solid blue;

And according to my test, the 5px here , solid, and blue can be swapped at will without affecting the display effect;

Moreover, this attribute is not part of the box model, so it does not occupy space and does not need to be calculated when using it. Width, height and other values ​​

are also supported by browsers: ie8+ and other mainstream browsers. Firefox even supports outline-radius, which is the same as border-radius

.

Looking from the "+" example


<p>第一个方法是使用outline-offset的向内偏移结合border实现的,不兼容所有IE,safari上也有点问题,要用chrome查看才行</p>
<p class="use-outline-offset"></p>


<style>
.use-outline-offset{
  margin-left: auto;
  margin-right: auto;
  width: 200px;
  height: 200px;
  border:40px solid #000000;
  background-color:#cccccc;
  outline-width:40px;
  outline-style:dotted;
  outline-offset:-80px;
  box-sizing: border-box;
}
</style>
Copy after login

there is also an attribute mentioned: outline-offset, which is the outline offset, here Negative values ​​are supported. This reminds me of paths in AI, and offset paths. Negative values ​​are offset inwards. Therefore, the "+" sign effect is achieved; the

outline-offset attribute is supported by all mainstream browsers, except IE (after testing, it is indeed not supported).

But this attribute does not take up space very well, it can improve work efficiency, and combined with outline-offset can achieve some unexpected effects;

The above is the detailed content of css3 outline attribute. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template