In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to achieve the CSS button for you. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Example 1:
First, we will give the general style of the button, including its active state. It is important to pay attention to relative positioning, as it will help us locate the:: before element later:
CSS
.a _ demo_one {
Background-color:#ba2323
Padding:10px
Position:relative
Font-family:'OpenSans',sans-serif
Font-size:12px
Text-decoration:none
Color:#fff
Border:solid1px#831212
Background-image:linear-gradient (bottom,rgb (171pr 27) 0% recorder RGB (212 pr 51) 100%)
Border-radius:5px
}
.a _ demo_one:active {
Padding-bottom:9px
Padding-left:10px
Padding-right:10px
Padding-top:11px
Top:1px
Background-image:linear-gradient (bottom,rgb (171pr 27) 100% recorder RGB (212 pr 51) 0%)
}
Then, we use the:: before pseudo element to create a gray container. Use absolute positioning to locate our elements:
CSS
.a _ demo_one::before {
Background-color:#ccd0d5
Content: ""
Display:block
Position:absolute
Width:100%
Height:100%
Padding:8px
Left:-8px
Top:-8px
Z-index:-1
Border-radius:5px
Box-shadow:inset0px1px1px#909193,0px1px0px#fff
}
Example 2:
CSS
.a _ demo_two {
Background-color:#6fba26
Padding:10px
Position:relative
Font-family:'OpenSans',sans-serif
Font-size:12px
Text-decoration:none
Color:#fff
Background-image:linear-gradient (bottom,rgb (100,170,30,100,170,30) 0% recordsrgb (129pence212pr 51) 100%)
Box-shadow:inset0px1px0px#b2f17f,0px6px0px#3d6f0d
Border-radius:5px
}
.a _ demo_two:active {
Top:7px
Background-image:linear-gradient (bottom,rgb (100,1701.30) 100% Personality RGB (129meme212pr 51) 0%)
Box-shadow:inset0px1px0px#b2f17f,inset0px-1px0px#3d6f0d
Color:#156785
Text-shadow:0px1px1pxrgba (255pr. 255pr. 0.3)
Background:rgb (44160202)
}
Because the location of the pseudo element depends on its parent element, once the parent element moves down a few pixels, it must move up the pseudo element with the same number of pixels.
CSS
.a _ demo_two::before {
Background-color:#072239
Content: ""
Display:block
Position:absolute
Width:100%
Height:100%
Padding-left:2px
Padding-right:2px
Padding-bottom:4px
Left:-2px
Top:5px
Z-index:-1
Border-radius:6px
Box-shadow:0px1px0px#fff
}
.a _ demo_two:active::before {
Top:-2px
}
Example 3:
The first thing we need to do is to create the simple part. Here, you will notice a right margin, which is to compensate for the width of the pseudo element, if you want to center the button.
.a _ demo_three {
Background-color:#3bb3e0
Font-family:'OpenSans',sans-serif
Font-size:12px
Text-decoration:none
Color:#fff
Position:relative
Padding:10px20px
Border-left:solid1px#2ab7ec
Margin-left:35px
Background-image:linear-gradient (bottom,rgb (44160202) 0% dint RGB (62184229) 100%)
Border-top-right-radius:5px
Border-bottom-right-radius:5px
Box-shadow:inset0px1px0px#2ab7ec,0px5px0px0px#156785,0px10px5px#999
}
.a _ demo_three:active {
Top:3px
Background-image:linear-gradient (bottom,rgb (62184229) 0% dint RGB (44160202) 100%)
Box-shadow:inset0px1px0px#2ab7ec,0px2px0px0px#156785,0px5px3px#999
}
Then there are pseudo elements:
.a _ demo_three::before {
Content: ""
Width:35px
Max-height:29px
Height:100%
Position:absolute
Display:block
Padding-top:8px
Top:0px
Left:-36px
Font-size:16px
Font-weight:bold
Color:#8fd1ea
Text-shadow:1px1px0px#07526e
Border-right:solid1px#07526e
Background-image:linear-gradient (bottom,rgb (10pc94125) 0% recordRGB (14139184) 100%)
Border-top-left-radius:5px
Border-bottom-left-radius:5px
Box-shadow:inset0px1px0px#2ab7ec,0px5px0px0px#032b3a,0px10px5px#999
}
.a _ demo_three:active::before {
Top:-3px
Box-shadow:inset0px1px0px#2ab7ec,0px5px0px0px#032b3a,1px1px0px0px#044a64,2px2px0px0px#044a64,2px5px0px0px#044a64,6px4px2px#0b698b,0px10px5px#999
}
This is the end of the article on "how to achieve the CSS button". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.