I'm trying to create a button like this:
This needs to be done in pure css.
I tried to do, nothing happened, it does not work correctly:
display: inline-block;
width: 165px;
text-align: center;
color: #fff;
background: linear-gradient(180deg, #4b3529 21%, #4c2e1a 100%);
border-radius: 5px;
border: 1px solid #ffffff;
font-family: Arial;
font-weight: normal;
border-left: 2px solid #e5ccaf;
border-image: linear-gradient(to bottom, #ffd400,rgba(0, 0, 0, 0)) 0 100%;
border-top: 1px solid #ffd400;
How can I do that?!
You can add the CSS properties inside a class. Then add the class to an HTML element with text-decoration: none; property as follows:
.pure_css_button {
display: inline-block;
width: 165px;
text-align: center;
color: #fff;
text-decoration: none;
background: linear-gradient(180deg, #4b3529 21%, #4c2e1a 100%);
border-radius: 5px;
border: 1px solid #ffffff;
font-family: Arial;
font-weight: normal;
border-left: 2px solid #e5ccaf;
border-image: linear-gradient(to bottom, #ffd400, rgba(0, 0, 0, 0)) 0 100%;
border-top: 1px solid #ffd400;
}
<a href="#" class="pure_css_button">
Button</a>
button {
cursor: pointer;
font-size: x-large;
padding: 0.6rem 2rem;
font-weight: bold;
overflow: hidden;
color: #fff;
background: linear-gradient(180deg, #4b3529 21%, #4c2e1a 100%);
border:0;
border-radius: .3rem;
position: relative;
border-top: 2px solid hsl(24, 49%, 15%);
border-bottom: 2px solid hsl(24, 49%, 15%);
}
button::after,button::before{
content: '';
height: 100%;
width: .15rem;
position: absolute;
top:0;
background:linear-gradient(to bottom, #ffd400, rgba(0, 0, 0, 0)) ;
}
button::before{
left: 0;
}
button::after{
right: 0;
}
<button>
Pure Css</button>
it's possible using body::after content "text" and style it
Related
I have about 100 buttons in my website, all using JavaScript onclick method. I want to replace them all with regular <a href> links for SEO purposes.
I made new class called button_seo with the same CSS as the old buttons. I placed it in the global CSS file, but it will not work and my buttons have no styling.
It does works when I place the CSS in the same file where the button is, but I would like to place it in the global file so I can control many buttons at once.
What might cause this? I don't have any style for the button_seo class anywhere in the files, just in global CSS file.
Here is my code:
.button_seo {
height: 40px ;
background: linear-gradient(to bottom, #4eb5e5 0%, #389ed5 100%); /* W3C */
border: none;
border-radius: 5px;
position: relative;
border-bottom: 4px solid #2b8bc6;
color: #fbfbfb;
font-weight: 600;
font-family: "Open Sans", sans-serif;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
font-size: 15px;
text-align: center;
text-indent: 5px;
box-shadow: 0px 3px 0px 0px rgba(0, 0, 0, 0.2);
cursor: pointer;
width: 190px;
left: 100px;
}
<a class="button_seo" style="left:30px;" href='../censord' title='censord'>Click >></a>
As comment to your answer, is this what you want?
.button_seo {
display: inline-block;
line-height: 40px; /* same as height */
height: 40px ;
background: linear-gradient(to bottom, #4eb5e5 0%, #389ed5 100%); /* W3C */
border: none;
border-radius: 5px;
position: relative;
border-bottom: 4px solid #2b8bc6;
color: #fbfbfb;
font-weight: 600;
font-family: "Open Sans", sans-serif;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
font-size: 15px;
text-align: center;
text-indent: 5px;
box-shadow: 0px 3px 0px 0px rgba(0, 0, 0, 0.2);
cursor: pointer;
width: 190px;
left: 100px;
}
<a class="button_seo" style="left:30px;" href='../censord' title='censord'>Click >></a>
EDIT - I found this SO
i fixed it, can't use height and width parameters for link, that not button after all.
I'm trying to center text in my button. I tried text-center: center; but it didn't help.
<button id="test" class="btn1" style="margin-left:8px;">Button 1</button>
css:
.btn1 {
display: inline-block;
border: 1px solid #ccc;
text-decoration: none;
word-wrap: normal;
vertical-align: middle;
text-center: center;
cursor: pointer;
border-radius: 2px;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
padding: 0 6px 0 5.5px;
height: 24px;
color: #6D6D6D;
background-color: #fafafa;
font-size: 11px;
font-family: "Roboto";
font-weight: 500;
}
.btn1:before {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAACXBIWXMAAAsSAAALEgHS3X78AAAAq0lEQVRYhe3ZOw7CQBCDYXuziRBISOH+FbfiAogKKlLsJhkKHhWNq2zhTz7Ar2mHl+t5ONxjzUBge2Say/OUh/1jd7zF2jeTVRHMEV2sfTvXAhDRvWt+a0EAkbaO+M9ZCmcpnKVwlsJZCmcpnKVwlsJZCmcpnKVwlsJZCmcpnKVwlsJZCmcpnKVwlsJZigzwuxZ8YjK5MFUAbbyiyFTJJZdpBKOdxx3TXKbxBb7NLc+2MdrpAAAAAElFTkSuQmCC') no-repeat left center transparent;
background-size: 100% 100%;
width: 14px;
height: 14px;
content: '';
display: inline-block;
vertical-align: middle;
margin-bottom: 1px;
margin-left: 3px;
margin-right: 8px;
}
.btn1:hover {
background: black;
background-image: -webkit-linear-gradient(top, #f7f9fa, #eff5f7);
background-image: -ms-linear-gradient(top, #f7f9fa, #eff5f7);
background-image: -o-linear-gradient(top, #f7f9fa, #eff5f7);
background-image: linear-gradient(to bottom, #f7f9fa, #eff5f7);
}
It needs moving text down by 1 px
https://jsfiddle.net/8dz1tfw7/1/
Will advised to use flex for that button
.test.btn1 {
display: flex;
align-items: center;
}
see below
.btn1 {
/**display: inline-block;**/
display: flex;
align-items: center;
border: 1px solid #ccc;
text-decoration: none;
word-wrap: normal;
vertical-align: middle;
text-center: center;
cursor: pointer;
border-radius: 2px;
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
padding: 0 6px 0 5.5px;
height: 24px;
color: #6D6D6D;
background-color: #fafafa;
font-size: 11px;
font-family: "Roboto";
font-weight: 500;
}
.btn1:before {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAACXBIWXMAAAsSAAALEgHS3X78AAAAq0lEQVRYhe3ZOw7CQBCDYXuziRBISOH+FbfiAogKKlLsJhkKHhWNq2zhTz7Ar2mHl+t5ONxjzUBge2Say/OUh/1jd7zF2jeTVRHMEV2sfTvXAhDRvWt+a0EAkbaO+M9ZCmcpnKVwlsJZCmcpnKVwlsJZCmcpnKVwlsJZCmcpnKVwlsJZCmcpnKVwlsJZigzwuxZ8YjK5MFUAbbyiyFTJJZdpBKOdxx3TXKbxBb7NLc+2MdrpAAAAAElFTkSuQmCC') no-repeat left center transparent;
background-size: 100% 100%;
width: 14px;
height: 14px;
content: '';
display: inline-block;
vertical-align: middle;
margin-bottom: 1px;
margin-left: 3px;
margin-right: 8px;
}
.btn1:hover {
background: black;
background-image: -webkit-linear-gradient(top, #f7f9fa, #eff5f7);
background-image: -ms-linear-gradient(top, #f7f9fa, #eff5f7);
background-image: -o-linear-gradient(top, #f7f9fa, #eff5f7);
background-image: linear-gradient(to bottom, #f7f9fa, #eff5f7);
}
<button id="test" class="btn1" style="margin-left:8px;"><span>Button 1</span></button>
Try adding
vertical-align: center;
Instead of
vertical-align: middle;
Here is drop down box I got to work for me.
But it goes outof boundry on left end. Actually menu items should fit exactly below the text box.
Check Fiddle
I tried changing width of all element but could not set it. Can some one tell me which class exactly controls width of menu item which appear when dropdown box is popped?
css:
.container {
width:90%;
margin:10% auto;
}
.dropdown-menu{
width:85%;
margin:0 auto;
}
.twitter-typeahead .tt-query, .twitter-typeahead .tt-hint {
margin-bottom: 0;
width: 360px; !important;
}
.twitter-typeahead .tt-hint {
display: block;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
border: 1px solid transparent;
border-radius:4px;
}
.twitter-typeahead .hint-small {
height: 30px;
padding: 5px 10px;
font-size: 12px;
border-radius: 3px;
line-height: 1.5;
}
.twitter-typeahead .hint-large {
height: 45px;
padding: 10px 16px;
font-size: 18px;
border-radius: 6px;
line-height: 1.33;
}
.tt-dropdown-menu {
min-width: 260px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, .2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.tt-suggestion {
display: block;
padding: 3px 20px;
}
.tt-suggestion.tt-is-under-cursor {
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
}
.tt-suggestion.tt-is-under-cursor a {
color: #fff;
}
.tt-suggestion p {
margin: 0;
}
On your class .dropdown-menu add this:
.dropdown-menu{
width:360px;
left:auto;
margin:0 auto;
}
The Fiddle demo
It's because 360px is the size of your input .twitter-typeahead .tt-query, .twitter-typeahead .tt-hint.
And the left:auto to keep the original distance no matter the absolute position.
I am using Jquery UI, and I need the jquery-ui.css for datepicker and buttonset. However, I am also using jquery tabs in the site.
I have added custom styling to the tabs in my own css folder (not jquery-ui.css), but when I add the jquery-ui.css it adds lots of other styling to my tabs, which look really bad.
I was wondering is there a way to remove the tabs styling from jquery-ui.css?
If it helps this is the html and styling for my tabs:
<ul id="product_tabs_list"><li>Description</li><li>Features</li><li>Specifications</li><li>Technical</li><div class="clr"></div></ul>
#product_tabs_list{
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-bottom: 10px;
padding: 11px 5px;
text-align: center;
}
#product_tabs_list li {
float: left;
}
#product_tabs_list li a {
background: #fff;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#fff), to(#eaeaea)) no-repeat;
background: -webkit-linear-gradient(#fff, #eaeaea) no-repeat;
background: -moz-linear-gradient(#fff, #eaeaea) no-repeat;
background: -ms-linear-gradient(#fff, #eaeaea) no-repeat;
background: -o-linear-gradient(#fff, #eaeaea) no-repeat;
background: linear-gradient(#fff, #eaeaea) no-repeat;
border: 1px solid #cfcfcf;
color: #3463a0;
font-weight: bold;
padding: 10px 20px;
-webkit-text-shadow: 1px 1px 1px #fff;
-moz-text-shadow: 1px 1px 1px #fff;
text-shadow: 0px 1px 1px #fff;
}
#product_tabs_list li a:hover {
background: #fff;
}
#product_tabs_list li.ui-tabs-active a {
background: #3463a0;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#3463a0), to(#233f64)) no-repeat;
background: -webkit-linear-gradient(#3463a0, #233f64) no-repeat;
background: -moz-linear-gradient(#3463a0, #233f64) no-repeat;
background: -ms-linear-gradient(#3463a0, #233f64) no-repeat;
background: -o-linear-gradient(#3463a0, #233f64) no-repeat;
background: linear-gradient(#3463a0, #233f64) no-repeat;
color: #fff;
-webkit-text-shadow: 1px 1px 1px #00204b;
-moz-text-shadow: 1px 1px 1px #00204b;
text-shadow: 0px 1px 1px #00204b;
}
I'm newbie. And I try to make a search box. When I open it on Firefox. It's okay for me. Then I do it in IE, Chrome and Safari. It's not cool actually. Anyone know my problems, please help me fix it?
I want make a search box like this: http://www.behance.net/gallery/Anthracite-EIKON/7171451
<div id="search-box">
<input type="text" name="search" placeholder="Search..."/>
</div>
And CSS:
*{ margin: 0; padding: 0; }
#search-box{
background: -moz-linear-gradient(top right, #353535, #010101);
background: -webkit-linear-gradient(top right, #353535, #010101);
background: -ms-linear-gradient(top right, #353535, #010101);
background: -o-linear-gradient(top right, #353535, #010101);
background: linear-gradient(top right, #353535, #010101);
padding: 30px 0;
position: relative;
}
input {
font-family: Cambria, 'Helvetica Neue',Helvetica,Arial,sans-serif;
font-size: 14px;
font-style: normal;
font-variant: normal;
color: #bebebe;
font-weight: 400;
line-height: 56px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5) ;
border-radius: 13px;
border: 1px solid #000000;
background-clip: border-box;
padding: 5px 4px 3px 24px;
width: 94px;
height: 27px;
box-shadow: 0 0 9px #121212 inset;
position: absolute;
right: 25px;
top: 15;
background-color: #444444 ;
background-image: url('images/search_icon.png');
background-repeat: no-repeat;
background-size: 12px 12px;
background-position: 9px 8px;
}
input:hover {
box-shadow: none;
}
input:focus {
width: 200px;
box-shadow: none;
text-shadow: none;
color: #4D4E52;
background-color: white ;
background-image: url('images/search_icon5.png');
background-repeat: no-repeat;
background-position: 9px 8px;
}
In your css for input you need to change top:15 to top:15px and change line-height to 24px;
Example: http://jsfiddle.net/justincook/sMG3R/