CSS Practice Record

Source: Internet
Author: User

The father of the son

Https://developer.mozilla.org/zh-CN/docs/Web/CSS/position

Using the sub-father phase to achieve a relatively old center way: 1. Clear width; 2. Position the left side to the middle of the container; 3.margin-left negative to move half of the element to the left, implementing the element container Center

<style>. Container{position:relative;    }. Item{position:Absolute;Background-color:#0F9E5E;Display:Inline-block;width:90px; Left:50%;Margin-left:-45px;Height:10px;    }</style><Divclass= "Container">    <Divclass= "Item"></Div></Div>
Small Triangle

The idea is simple, is the input method to enter a diamond, and then hide half of the line.

<stylerel= "stylesheet">. Tri:before{content:' ◇ ';Line-height:1;font-size:30px;Display:Inline-block;Height:15px;Overflow:Hidden;    }</style><spanclass= "tri"></span>
+ and ~ Selectors

Div+p: Select a <p> element immediately after the <div> element.

P~ul: Selects all <ul> elements after the <p> element.

Scenario: Select all the elements that you think are the first one. Here are two ways to achieve

<style>    /*. Item ~. Item*/. Item +. Item{Color:Red;    }</style><Divclass= "Item First">1</Div><Divclass= "Item">2</Div><Divclass= "Item">3</Div><Divclass= "Item">4</Div>

Operation Result:

1234
row height and font size are the same

Line-height:1

translucent container, opaque content

Using opacity will cause the container and content to be transparent, using RGBA to make the container transparent, but the content is opaque

<style>. Container{Background-color:Rgba (99,99,99,0.5);    }</style><Divclass= "Container">123131</Div>

CSS Practice Record

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.