HTML and CSS Basic courses (10) style with class and ID for div

Source: Internet
Author: User

This class is mainly to review the contents of the previous lesson, will use Div to create a few circles, let class and ID to set their style.

The attributes involved:

Display:inline-block

border-radius:100%;

margin-left:5px

will be speaking in the course of the following

Stylesheet.css

/*add your CSS below!*/  
      
div {  
    display:inline-block;  
    margin-left:5px;  
    height:100px;    
    width:100px;  
    border-radius:100%;  
    border:2px solid black;  
Friend {  
    border:2px dashed #008000;  
}  
. Family {  
    border:2px dashed #0000FF;  
}  
. Enemy {  
    border:2px dashed #FF0000;  
}  
#best_friend {  
    border:4px solid #00C957;  
}  
#archnemesis {  
    border:4px solid #CC0000;  
}

Index.html

<! DOCTYPE html>  

More Wonderful content: http://www.bianceng.cn/web/Html/

Effect Chart:

As you can see from the effect, class friend and ID Best_friend, as well as enemy and archnemesis, are both referenced by a Div, and the result is best_friend, which shows that the ID has a higher priority than class.

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.