In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What this article shares with you is an example analysis of the advanced practical skills of CSS. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
Use: not () to apply / unapply borders on menus
Add a border to each menu item first
CSS Code copies content to the clipboard
/ * add border * /
.nav li {
Border-right: 1px solid # 666
}
…… And then remove the last element.
CSS Code copies content to the clipboard
/ / * remove border * /
.nav li:last-child {
Border-right: none
}
…… You can directly use the: not () pseudo class to apply the element:
CSS Code copies content to the clipboard
.nav li:not (: last-child) {
Border-right: 1px solid # 666
}
This makes the code clean, easy to read, and easy to understand.
Of course, if your new element has a sibling element, you can also use the general sibling selector (~):
CSS Code copies content to the clipboard
.. nav li:first-child ~ li {
Border-left: 1px solid # 666
}
Add line heights to body
You don't need to add line-height to each separately
Wait. Simply add to body:
CSS Code copies content to the clipboard
Body {
Line-height: 1
}
This makes it easy for text elements to inherit from body.
Everything is vertically centered.
It's too easy to center all elements vertically:
CSS Code copies content to the clipboard
Html, body {
Height: 100%
Margin: 0
}
Body {
-webkit-align-items: center
-ms-flex-align: center
Align-items: center
Display:-webkit-flex
Display: flex
}
Look, isn't it easy.
Note: beware of flexbox in IE11.
Comma separated list
Make the HTML list items look like a real, comma-separated list:
CSS Code copies content to the clipboard
Ul > li:not (: last-child):: after {
Content: ",
}
Use the: not () pseudo class for the last list item.
Select a project using a negative nth-child
Use negative nth-child in CSS to select items 1 to n.
CSS Code copies content to the clipboard
Li {
Display: none
}
/ * select items 1 through 3 and display them * /
Li:nth-child (- nasty 3) {
Display: block
}
It's that easy.
Use SVG with icons
There is no reason why we should not use SVG for icons:
CSS Code copies content to the clipboard
.logo {
Background: url ("logo.svg")
}
SVG is scalable for all resolution types and supports all browsers to return to IE9. This avoids .png, .jpg, or .gif files.
Optimize display of text
Sometimes fonts don't work best on all devices, so you can ask the device browser to help you:
CSS Code copies content to the clipboard
Html {
-moz-osx-font-smoothing: grayscale
-webkit-font-smoothing: antialiased
Text-rendering: optimizeLegibility
}
Note: please use optimizeLegibility responsibly. In addition, IE / Edge does not have text-rendering support.
Use max-height for pure CSS sliders
Use max-height and overflow hiding to implement the CSS-only slider:
CSS Code copies content to the clipboard
.slider ul {
Max-height: 0
Overlow: hidden
}
.slider: hover ul {
Max-height: 1000px
Transition: .3s ease
}
Inherit box-sizing
Let box-sizing inherit html:
CSS Code copies content to the clipboard
Html {
Box-sizing: border-box
}
*, *: before, *: after {
Box-sizing: inherit
}
This makes it easier to change the box-sizing in other components of plug-ins or other behaviors of leverage.
Table cells are equal in width
Tables are troublesome to work with, so be sure to use table-layout: fixed as much as possible to keep cells equal in width:
CSS Code copies content to the clipboard
.calendar {
Table-layout: fixed
}
Use Flexbox to get rid of all kinds of hack with outer margin
When you need to use column delimiters, you can get rid of the hack of nth-,first-, and last-child through the space-between property of flexbox:
CSS Code copies content to the clipboard
.list {
Display: flex
Justify-content: space-between
}
.list .person {
Flex-basis: 23%
}
The list delimiter now appears at evenly spaced locations.
Use the property selector for empty links
Displays a link when the element has no text value but the href attribute has a link:
CSS Code copies content to the clipboard
A [href ^ = "http"]: empty::before {
Content: attr (href)
}
It's quite convenient.
The above is an example analysis of CSS's advanced practical skills, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.