I want to know how to add a small icon in this button aligned on left with the text
<a class="button" href="#">button</a>
.button { padding: 15px 15px;
background: #000;
border-radius: 3px;
color: #fff;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;}
JSfiddle
Add a span to your text and put a background aligned to the left for this span.
<a class="button" href="#"><span>button</span></a>
.button span {
background:url('http://www.freesmileys.org/smileys/smiley-laughing002.gif') no-repeat;
padding-left: 20px;}
Fiddle -> http://jsfiddle.net/fg3tK/6/
If I understand your question correctly, here is the example - http://jsfiddle.net/u2py3/
.button {
border: 1px solid #563d7c;
border-radius: 5px;
color: white;
padding: 5px 10px 5px 25px;
background-image:
url(https://cdn.sstatic.net/stackoverflow/img/sprites.png?v=6);
background-position-y: 465px;
background-position-x: 5px;
background-color: #563d7c;
}
Wouldn't this do it?
<a class="button" href="#"><img src="xxx"/>button</a>
Or are you looking for somthing more complicated?
It's a pretty common practice to add padding-left to your button, and position a background to fill that gap that's created.
.button {
background: #666 url('https://cdn.sstatic.net/stackoverflow/img/sprites.png?v=6') 5px -188px no-repeat;
border-radius: 3px;
color: #fff;
font-size: 14px;
font-weight: bold;
padding: 10px 15px 10px 40px; /*Add some left padding*/
text-transform: uppercase;
}
Here's a FIDDLE
.button {
background: #000 url('https://cdn1.iconfinder.com/data/icons/iconslandtransport/PNG/24x24/CabrioletRed.png') 5px 45% no-repeat;
padding: 15px 15px 15px 35px;
border-radius: 3px;
color: #fff;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
}
In case that you have multiple buttons and you want different image for each use :nth-child() pseudo class to target each button e.g.
.button:nth-child(2) {
background: red url( ... ) 5px 45% no-repeat;
}
.button:nth-child(3) {
background: blue url( ... ) 5px 45% no-repeat;
}
...
Related
I had a email textbox with default,success,error css class.
<input id="emailInput" class="sansserif inputuser" style=" margin-top: 5px;" type="text" placeholder="Enter Email.."/>
.default{
width: 306px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
color: #737373;
font-weight: 600;
background-color: white;
background-image: url('../Styles/Icons/User Male-35.png');
background-position: 5px 5px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}
.error{
width: 306px;
box-sizing: border-box;
border: 2px solid #ff0000;
border-radius: 4px;
font-size: 16px;
color: #737373;
font-weight: 600;
background-color: white;
background-image: url('../Styles/Icons/User Male-35.png');
background-position: 5px 5px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}
.success{
width: 306px;
box-sizing: border-box;
border: 2px solid #00b33c;
border-radius: 4px;
font-size: 16px;
color: #737373;
font-weight: 600;
background-color: white;
background-image: url('../Styles/Icons/User Male-35.png');
background-position: 5px 5px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}
here i'm applying following css classes default ,error and success while validating email text box but only difference from the above three classes is border property only .how to reduce the redundant css properties is there any better way to achieve this.
You can define similar css at one place with joining multiple selectors and overriding later if necessary:
Note: The styles that you are overriding i.e for .error and .success must come after the generic styles otherwise they will be overridden by default styles and you won't see any change.
.default,
.error,
.success {
width: 306px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
color: #737373;
font-weight: 600;
background-color: white;
background-image: url('../Styles/Icons/User Male-35.png');
background-position: 5px 5px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}
.error {
border-color: #ff0000;
}
.success {
border-color: #00b33c;
}
I want to show a p tag or legend tag or any html text like button. But how is it possible? I have tried with css but not working well.
I want to show it like button.
<p class="button" >Submit</p>
or
<a class="button" >Submit</a>
or
<legend class="button" >Submit</legend>
Now need the button class.
Just apply css styles and cursor: pointer; to it to make it appear that it's a button
.button{
display: inline-block;
background: #000;
border-radius: 4px;
font-family: "arial-black";
font-size: 14px;
color: #FFF;
padding: 8px 12px;
cursor: pointer;
}
JSFIDDLE
It is simple with css.
<p class='btn'> Button 1 </p>
And Your CSS
.btn{
float:left;
width:auto;
height:30px;
display:block;
border:1px solid #ff6600;
background:#00ff00;
color:#000;
line-height:30px;
text-align:center;
padding:0 20px;
border-radius:3px;
}
.btn:hover{
cursor:pointer;
}
jsfiddle : http://jsfiddle.net/ob67xnw4/1/
Try This.
Here is the Working FIDDLE
CSS
.button {
width: 75px;
background: #d2d2d2;
text-align: center;
float: left;
color: #000;
line-height: 32px;
text-decoration: none;
}
.button: hover{
width: 75px;
background: #0e567f;
color: #fff;
text-align: center;
float: left;
line-height: 32px;
text-decoration: none;
}
<p class='button'> Submit </p>
.button{
background: -webkit-linear-gradient(top, #CCB5B6 20%, #274936 70%);
width: 100px;
height: 40px;
font-family: sans-serif;
font-size: 25px;
text-align: center;
line-height: 40px;
color: #96F256;
border-radius: 10px;
box-shadow: 0 2px 5px 3px black;
cursor: pointer;
}
.button:hover{
color: white;
}
OUTPUT
I think you should use this code and it is working well. You can change Color according to you.
Live Demo
HTML Code:
<input class="round-button-circle" type="submit" value="Submit"/>
CSS Code:
.round-button-circle {
width: 150px;
height:50px;
border-radius: 10px;
border:2px solid #cfdcec;
overflow:hidden;
font-weight: 15px;
background: #4679BD;
box-shadow: 0 0 3px gold;
}
.round-button-circle:hover {
background:#30588e;
}
Result:
Had just got what did I want.
DEMO JSFIDDLE
.button {
display: inline-block;
outline: none;
cursor: pointer;
border: solid 1px #da7c0c;
background: #478dad;
text-align: center;
text-decoration: none;
font: 14px/100% Arial, Helvetica, sans-serif;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
border-radius: .3em;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.button:hover {
background: #f47c20;
background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
background: -moz-linear-gradient(top, #f88e11, #f06015);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}
.button:active {
position: relative;
top: 1px;
}
I am trying following code for executing one alignment of boxes in right side with two adjacent box in row, please check below code why that main DIV class list_right css in not executing.
Fiddle link.
<style>
.list_right {
float:right;
padding:40px 5px 0px 0px;
width:37%;
position:relative;
}
.part_1 {
width:50%;
float:left;
line-height: 1.7;
}
.logos {
float: left;
width:160px;
margin-left:0px;
margin-bottom:8px;
padding-left: 45px;
padding-top: 1px;
padding-bottom: 3px;
text-decoration: none;
font-family:'Volkhov', arial;
font-size: 19px;
letter-spacing: 1.3px;
line-height: 2.14;
color: #6d6e71;
border: 1px solid;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: #666 0px 2px 3px;
-moz-box-shadow: #666 0px 2px 3px;
box-shadow: #666 0px 2px 3px;
border-color: #41c7ee;
behavior: url(/css/pie/PIE.htc);
}
.logos:hover {
border-color: #6d6e71;
background-color: #41c7ee !important;
color: #ffffff !important;
text-decoration: none !important;
}
.site_1 {
background-image: url(http://i.imgur.com/ndWHvar.png) !important;
background-color: #f1f1f1 !important;
background-repeat:no-repeat !important;
background-position: 0px -5px !important;
height:36px;
}
.site_2 {
background-image: url(http://i.imgur.com/ndWHvar.png) !important;
background-color: #f1f1f1 !important;
background-repeat:no-repeat !important;
background-position: 0px -5px !important;
height:36px;
}
</style>
<div class="list_right">
<div class="part_1">
Sites
</div>
<div class="part_1">
Sites
</div>
<div class="d_hidden">
</div>
<div class="clear_both">
</div>
Seems to me (from your code) that you are not closing the list_right tag. Close it and it should work properly... try to indent your code, make it look more clean, so that in the future you will be able to see the problems yourself.
You have <style> tags in your css in your original fiddle link which demonstrates the problem your were having.
Delete them, they shouldn't be there.
That's what's interfering with the list_right class.
FIDDLE
HTML code:
<div class="col-lg-7 col-md-7 col-sm-7">
<select class="tblselect2 ">
<option value="">Item 1</option>
<option value="">Item 1</option>
</select>
</div>
I am using this CSS for formatting the select option.
.tblselect2 {
background: url("../images/arrow1.png") no-repeat scroll right center white;
font-size: 12px;
height: 18px;
line-height: 1.5;
margin-bottom: 0px;
padding: 2px 0 17px 0;
line-height: 1.5;
border: 1px solid #d9d9d9;
border-radius: 4px;
color: #555555;
width: 64%;
}
When I am using this css the selected value does not come into the select box. I need to add this css however, for formatting the select button. I need to add a image for right drop down.
It is hiding because of the height and padding you have used in your CSS. Update your CSS like below.
.tblselect2 {
background: url("../images/arrow1.png") no-repeat scroll right center white;
font-size: 12px;
height: 24px;
line-height: 1.5;
margin-bottom: 0px;
padding: 2px 0 4px 0;
line-height: 1.5;
border: 1px solid #d9d9d9;
border-radius: 4px;
color: #555555;
width: 64%;
}
EDIT:
If you want hide the original arrow of selectbox use the following CSS. But this solution will work onlly IE10+ browsers, chrome. IE older browser it wont work.
.tblselect2 {
background: url("http://www.fifa.com/imgml/icons/events/arrow_Down_Red.gif") no-repeat 99% 5px white;
font-size: 12px;
height: 24px;
line-height: 1.5;
margin-bottom: 0px;
padding: 2px 0px 4px 0;
line-height: 1.5;
border: 1px solid #d9d9d9;
border-radius: 4px;
color: #555555;
width: 64%;
appearance:none;
-moz-appearance:none; /* Firefox */
-webkit-appearance:none;
}
.col-lg-7 select::-ms-expand{
display: none;
}
FIDDLE DEMO
Adjust Following line in your css code and give height
padding: 2px 0 10px 0;
height:30px;
http://jsfiddle.net/58KmZ/2/
remove padding from your css code
padding:
You should increase the height and decrease the padding-bottom. If you change, it will be shown.
height: 25px;
padding: 2px 0px 5px 0px;
I am trying to get different 's to look differently, depending on the context. For example, in my html I have
<li> Home </li>
<li> Types of Insurance </li>
<li> Insurance Basics </li>
<li> Customer Center </li>
<li> About </li>
and in my css I have
.navlink : link
{
display:block;
width:120px;
text-align:center;
padding:10px;
text-decoration:none;
color:#FFFFFF;
}
.navlink : hover
{
background-color:#ADD8E6;
}
.navlink : visited
{
background-color:#ADD8E6;
}
But this is not working (the links appear unstylized). How would I fix this?
There must be no space before or after the :.
You need to get rid of the space before and after the colon (:).
You can also minimize your code by doing this:
.navlink {
// styling for unclicked link
}
.navlink:hover, .navlink:visited {
// styling for hover/visited state
}
I'm combining hover and visited because the only change you've made is the color, and it's the same for both.
Demo.
#nav{
float: left;
display: block;
font-size: 16px;
/*font-weight: bold;*/
font-family: 'Georgia', serif;
}
#nav>li{
display: block;
float: left;
line-height: 36px;
padding-right: 10px;
margin-left: 3px;
margin-right: 3px;
background: url(../img/nav-bullet.png) no-repeat center right;
}
#nav li>a:first-letter {
font-family: 'YataghanRegular', 'Georgia', serif;
font-size: 20px;
}
#nav li>a{ /* Parent Menu without hover*/
text-decoration: none;
color: #000000;
/*color: #CC3700; 606060*/
padding: 0px 10px 0px 10px;
display: block;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#nav li:last-child{
background: none;
}
#nav>li:hover>a,
#nav>li.current-menu-item>a{/* Parent menu color with hover */
/*color: #eee;
background: #363636;*/
color:#000000;
background: #cce4ff ;
/*font-size: 12px;*/
/*background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#353535));
background: -moz-linear-gradient(top, #000000, #353535);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#353535', GradientType=0);*/
/*text-shadow: 0 -1px rgba(0, 0, 0, 0.7);*/
-webkit-box-shadow: 0px 1px 2px rgba(0,0,0,.5);
-moz-box-shadow: 0px 1px 2px rgba(0,0,0,.5);
box-shadow: 0px 1px 2px rgba(0,0,0,.5);
}
Try This..