The border of CSS properties

Source: Internet
Author: User
CSS Border Properties I believe everyone is not unfamiliar, is to add a border to the element, in different box model, will give the element of the width of the impact of how, I believe we are very familiar with, here will not repeat, only to say that we usually do not pay attention to things.

0.border-color and color

When you use border property, you should usually write the border:1px solid #ccc directly. It looks like this.

But do you know what color it is when you don't set the color for border? I'm sure there will be a lot of people saying, black!

It's black, but why is it black? Because the element color property is black by default when no color attribute is set for an element, that is, when Border-color is not set, Border-color=color.

<p class= "wrap" >  <p class= "Red" > No color set for border </p></p>

* {margin:0; padding:0;}. Wrap {  position:relative;  width:400px;  height:400px;  margin:50px Auto;}. Red {  width:100px;  height:100px;  color:red;  BORDER:2PX solid;}

1.border and graphics

Four direction of the border is actually how to compose, I believe a lot of people know, here again write a write, only need to cooperate with transparent(transparent), you can achieve a lot of graphics, such as triangles, we can try it yourself.

<p class= "box" ></p>

. box {  position:absolute;  border-top:20px solid red;  border-left:20px solid blue;  border-right:20px solid Green;  border-bottom:20px solid Yellow;}

2.border and equal height layouts

Use border to achieve high-left and right-side layouts, with margin-left negative values

<ul class= "List" >  <li class= "Item" >    <span class= "left" > LH high </span>    Here are some of the main things  </li>  <li class= "Item" >    <span class= "left" > LH high </span>    Here are some of the main things  </li>  <li class= "Item" >    <span class= "left" > LH high </span>    Here are some of the main things  </ Li></ul>

* {margin:0; padding:0;}. list {  margin:50px;}. item {  width:500px;  List-style:none;  border-left:200px solid Green;  background-color:red;}. Left {  margin-left: -200px;  margin-right:200px;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.