How to position background image in a button - html

I have the following CSS:
.physButton:before {
content: " ";
display: inline-block;
background: url("../theImages/ste.png") no-repeat;
height: 38px;
line-height: 38px;
vertical-align: middle;
width: 52px;
/*margin-left: 10%;*/
}
.locButton:before {
content: " ";
display: inline-block;
background: url("../theImages/loc.png") no-repeat;
height: 38px;
line-height: 38px;
vertical-align: middle;
width: 52px;
/*margin-left: 10%;*/
}
.mwmButton:before {
content: " ";
display: inline-block;
background: url("../theImages/loc.png") no-repeat;
height: 38px;
line-height: 38px;
vertical-align: middle;
width: 52px;
/*margin-left: 10%;*/
}
button {
border: 1px solid rgba(0,0,0,0.3);
background: #eee;
color: #515151;
font-size: 24px;
font-weight: 700;
padding: 21px 34px;
text-decoration: none;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.21, rgb(203,203,203)), color-stop(0.58, rgb(227,226,226)));
background: -moz-linear-gradient(center bottom, rgb(203,203,203) 21%, rgb(227,226,226) 58%);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 0 0 5px rgba(255,255,255,0.3) /* glass edge */, inset 0 1px 0 0 rgba(255,255,255,0.5) /* top highlight */, inset 0 -3px 0 0 rgba(0,0,0,0.5) /* bottom shadow */;
-webkit-box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 1px 0 0 rgba(255,255,255,0.5), inset 0 -3px 0 0 rgba(0,0,0,0.5);
box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 1px 0 0 rgba(255,255,255,0.5), inset 0 -3px 0 0 rgba(0,0,0,0.5);
text-shadow: 0 1px rgba(255,255,255,0.6);
}
button::-moz-focus-inner, a.button::-moz-focus-inner {
padding:0;
border:0;
}
button:hover, a.button:hover {
background: #cbcbcb;
cursor: pointer;
}
button:active, a.button:active {
background: #ccc;
padding: 22px 34px 20px; /* Bump down text */
-moz-box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 -1px 0 0 rgba(255,255,255,0.5), inset 0 2px 5px 0 rgba(0,0,0,0.2);
-webkit-box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 -1px 0 0 rgba(255,255,255,0.5), inset 0 2px 5px 0 rgba(0,0,0,0.2);
box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 -1px 0 0 rgba(255,255,255,0.5), inset 0 2px 5px 0 rgba(0,0,0,0.2);
text-shadow: none;
}
.locButton {
background: #e1001a;
color: #fff;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.21, rgb(192,0,22)), color-stop(0.58, rgb(226,0,26)));
background: -moz-linear-gradient(center bottom, rgb(192,0,22) 21%, rgb(226,0,26) 58%);
text-shadow: 0 1px rgba(0,0,0,0.25);
}
.locButton:hover {
background: #cb0018;
text-shadow: 0 1px rgba(0,0,0,0);
}
.locButton:active {
background: #ae0014;
}
.mwmButton {
background: #E05A00;
color: #fff;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.21, rgb(192,63,0)), color-stop(0.58, rgb(224,74,0)));
background: -moz-linear-gradient(center bottom, rgb(192,63,0) 21%, rgb(224,74,0) 58%);
text-shadow: 0 1px rgba(0,0,0,0.25);
}
.mwmButton:hover {
background: #CA7700;
text-shadow: 0 1px rgba(0,0,0,0);
}
.mwmButton:active {
background: #AC6900;
}
which displays the following:
How do I modify the above code the the images aligns to the left and the text aligns to the right as shown here:

HTML:
<div id="mbLOnlyButtons">
<button class="mwmButton" style="width: 95%;"><span class="icon"> </span><span class="text">My WESTMED</span></button>
<div style="clear: both;"><br></div>
<button class="physButton" style="width: 95%;"><span class="icon"> </span><span class="text">Physicians</span></button>
</div>
CSS:
button .text { width: 50%; display: inline-block; text-align:left;}
button .icon { width: 50%; display: inline-block; background: url("http://www.westmedgroup.com/images/HealthCareReformv2.jpg") top right no-repeat; }
This sets up two separate regions within your buttons.

In the bottom picture, the space between image and text are different - just add a bit of padding right on the locButton and physButton :before pseudo elements until they align, you'll need 4-10px.

Place a span around the text and give it a standard width that is big enough for all the buttons (lets say 100px). Now apply this css style:
width:100px;
text-align:right;
the icon will stay on the left (it's default place), and the text will allign

Related

how to give different padding styles to ng-repeat elements? [duplicate]

This question already has answers here:
Are class names in CSS selectors case sensitive?
(4 answers)
Closed 4 years ago.
http://skymics.com/Energy/sampleschematic.jpg see this picture.i want my 6 boxes go on the 6 vertical lines above the picture. i dont know how to give different padding styles to this ng-repeat I have used.i have used [ng-class] but it does not work.i have serched the internet all sources talked about ng-class.i dont know if i used it correctly or not.it is nessecary .please help .
<div style="background-color: white">
<div id="container" class="row" style="padding-left: 150px">
<div class="col-md-6" ng-repeat="row in msg.payload"
ng-class=" {'evenClass': $even, 'oddClass': $odd , 'firstClass':$first,'lastClass':$last} ">
<div class="plan col-md-4">
<h3>Voltage : {{row.Voltage}}
<span ng-class="row.Switch " ng-if="row.Switch == 'OFF'"
style="background: red">{{row.Switch}}</span>
<span ng-class="row.Switch" ng-if="row.Switch == 'ON'"
style="background: green">{{row.Switch}}</span>
</h3>
<script>
$(document).ready(function () {
setInterval(function (blinker) {
$("span").fadeIn(500);
$("span").fadeOut(500);
}, 1000)
});
</script>
<div class="Amp">Amp</div>
<ul>
<li><b>P1: </b>{{row.P1}}</li>
<li><b>P2: </b>{{row.P2}}</li>
<li><b>P3: </b>{{row.P3}}</li>
<li><b>N: </b>{{row.N}}</li>
</ul>
</div>
</div>
</div>
and my css is :
<style>
body, html {
height: 100%;
margin: 0;
/*background: #303030;*/
}
.bg {
/* The image used */
background-image: url("http://skymics.com/Energy/sampleschematic.jpg");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
#container {
/*margin: 100px auto;*/
text-align: center;
/*width: 892px; !*/
}
#container .plan {
font: 12px 'Lucida Sans', 'trebuchet MS', Arial, Helvetica;
text-shadow: 0 1px rgba(255, 255, 255, .8);
background: #fff;
border: 1px solid #ddd;
color: #333;
padding: 20px;
/*width: 134px; !* plan width = 180 + 20 + 20 + 1 + 1 = 222px *!*/
float: left;
opacity: 0.9;
position: relative;
}
/*#container .plan:nth-child(1) {*/
/*-moz-border-radius: 5px 0 0 5px;*/
/*-webkit-border-radius: 5px 0 0 5px;*/
/*border-radius: 5px 0 0 5px;*/
/*}*/
/* --------------- */
#container h3 {
font-size: 20px;
font-weight: normal;
padding: 20px;
margin: -20px -20px 50px -20px;
background-color: #eee;
background-image: -moz-linear-gradient(#fff, #eee);
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#eee));
background-image: -webkit-linear-gradient(#fff, #eee);
background-image: -o-linear-gradient(#fff, #eee);
background-image: -ms-linear-gradient(#fff, #eee);
background-image: linear-gradient(#fff, #d9edf7);
}
/*#container .plan:nth-child(1) h3 {*/
/*-moz-border-radius: 5px 0 0 0;*/
/*-webkit-border-radius: 5px 0 0 0;*/
/*border-radius: 5px 0 0 0;*/
/*!*}*!*/
#container h3 span {
display: block;
font: bold 25px/100px Georgia, Serif;
color: #777;
background: #F21432;
border: 5px solid #fff;
height: 100px;
width: 100px;
margin: 10px auto -65px;
-moz-border-radius: 100px;
-webkit-border-radius: 100px;
border-radius: 100px;
-moz-box-shadow: 0 5px 20px #ddd inset, 0 3px 0 #999 inset;
-webkit-box-shadow: 0 5px 20px #ddd inset, 0 3px 0 #999 inset;
box-shadow: 0 5px 20px #ddd inset, 0 3px 0 #999 inset;
}
/* --------------- */
#container ul {
margin: 20px 0 0 0;
padding: 0;
list-style: none;
}
#container li {
border-top: 1px solid #ddd;
padding: 10px 0;
}
/* --------------- */
#container .Amp {
position: relative;
padding: 8px 20px;
/*margin: 20px 0 0 0;*/
color: #fff;
font: bold 14px Arial, Helvetica;
text-transform: uppercase;
text-decoration: none;
/*display: inline-block;*/
background-color: #0b97c4;
background-image: -moz-linear-gradient(#0b97c4, #0b97c4);
background-image: -webkit-gradient(linear, left top, left bottom, from(#0b97c4), to(#0b97c4));
background-image: -webkit-linear-gradient(#0b97c4, #0b97c4);
background-image: -o-linear-gradient(#0b97c4, #0b97c4);
background-image: -ms-linear-gradient(#0b97c4, #0b97c4);
background-image: linear-gradient(#0b97c4, #0b97c4);
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
text-shadow: 0 1px 0 rgba(0, 0, 0, .3);
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 2px 0 rgba(0, 0, 0, .7);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 2px 0 rgba(0, 0, 0, .7);
box-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 2px 0 rgba(0, 0, 0, .7);
}
.evenClass {
}
.oddClass {
}
.firstClass {
padding-top: 40px;
}
.lastClass {
}
You are using ng-class the wrong way!
The actual way of using it is as below-
ng-class="{'evenClass': $even, 'oddClass': $odd, 'firstClass': $first, 'lastClass': $last}"
And for a class defined in a single var (e.g. var className = 'bla';)-
ng-class="bla"

How do I send this backwards using z-index?

.line {
text-align: center;
font-family:big;
font-size:60px;
text-shadow: -1px 0 0 #FFFFFF, 1px 1px 0 #CCCCCC,
2px -1px 0 #FFFFFF, 3px 0 0 #FFFFFF;
color:#2F1C0A;
background: #A89D7D url("brown.jpg") repeat-x right top;
border-bottom: solid #4E4A45 0.25em;
padding: 20px 0px 20px 0px;
margin: 0px 0px 0px 0px;
position:relative;
z-index:-1;
}
I want to send it backwards to bring the image old.png (below is the code) forward:
body{
background: #AC9175 url("old.png") repeat-y right top;
background-size:5%;
}

How to add an image to a custom CSS button

I have the following button HTML code:
<button class="button" style="width: 95%;">PHYSICIANS</button>
It is customized by CSS3 here:
button {
border: 1px solid rgba(0,0,0,0.3);
background: #eee;
color: #515151;
font-size: 24px;
font-weight: 700;
padding: 21px 34px;
text-decoration: none;
background: -webkit-gradient(linear, left bottom, left top, color-stop(0.21, rgb(203,203,203)), color-stop(0.58, rgb(227,226,226)));
background: -moz-linear-gradient(center bottom, rgb(203,203,203) 21%, rgb(227,226,226) 58%);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 0 0 5px rgba(255,255,255,0.3) /* glass edge */, inset 0 1px 0 0 rgba(255,255,255,0.5) /* top highlight */, inset 0 -3px 0 0 rgba(0,0,0,0.5) /* bottom shadow */;
-webkit-box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 1px 0 0 rgba(255,255,255,0.5), inset 0 -3px 0 0 rgba(0,0,0,0.5);
box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 1px 0 0 rgba(255,255,255,0.5), inset 0 -3px 0 0 rgba(0,0,0,0.5);
text-shadow: 0 1px rgba(255,255,255,0.6);
}
button::-moz-focus-inner, a.button::-moz-focus-inner {
padding:0;
border:0;
}
button:hover, a.button:hover {
background: #cbcbcb;
cursor: pointer;
}
button:active, a.button:active {
background: #ccc;
padding: 22px 34px 20px;
-moz-box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 -1px 0 0 rgba(255,255,255,0.5), inset 0 2px 5px 0 rgba(0,0,0,0.2);
-webkit-box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 -1px 0 0 rgba(255,255,255,0.5), inset 0 2px 5px 0 rgba(0,0,0,0.2);
box-shadow: 0 0 0 5px rgba(255,255,255,0.3), inset 0 -1px 0 0 rgba(255,255,255,0.5), inset 0 2px 5px 0 rgba(0,0,0,0.2);
text-shadow: none;
}
Which displays the following button:
How can I modify the above code, so I can add a thumbnail image to it. Something like this:
The default image size is 260X190 but I want to size it up so it fits inside the button.
You can use the pseudo-element :before to do this.
See this working demo I made: http://jsfiddle.net/A7UsX/1/
button:before {
content: " ";
display: inline-block;
background: url("http://www.wdc.com/Global/images/icons/icon_supporthelp.gif") no-repeat;
height: 30px;
width: 50px;
}
I have made a red background to show you what I did. Change the background to the image you would like and change the height and width to your likings.
you could use :before pseudo element.
button:before{content: ' '; display:inline-block; position:absolute; content:url(http://lorempixel.com/25/25); }
I'll suggest you to use a SVG image rather than using jpg or png format. so in this case you can call the image using background-image and give a positioning too.
button:before { content:''; display:inline-block; height:1em; width:1em;
background-image:url('images/image.svg'); background-size:contain; background-repeat:no-repeat; }
here you can check the working Demo. http://jsbin.com/damujidi/1/edit
You can add a <i> as commonly used in bootstrap [ref1] [ref2].
<button class="button">
<i class="btnbg"></i>PHYSICIANS
</button>
CSS:
.btnbg {
background-image: url('http://i.stack.imgur.com/QgIOj.png');
background-position: bottom left;
background-repeat: no-repeat;
background-size: contain;
display: inline-block;
height: 35px;
line-height: 35px;
vertical-align: middle;
width: 70px;
}
.button {
line-height: 35px;
vertical-align: middle;
}
see jsFiddle

How to make css search form responsive

i am trying to make use of min-width , max-width property but was unable to achieve the results as desired.
here is the code
HTML
<form class="form-wrapper-01">
<input id="search" type="text" />
<input id="submit" type="submit" value="Search" />
</form>
CSS
.form-wrapper-01 {
max-width: 450px;
width:100%;
padding: 10px;
margin: 100px auto;
overflow: hidden;
border-width: 1px;
border-style: solid;
border-color: #dedede #bababa #aaa #bababa;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
background-color: #f6f6f6;
background-image: -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#eae8e8));
background-image: -webkit-linear-gradient(top, #f6f6f6, #eae8e8);
background-image: -moz-linear-gradient(top, #f6f6f6, #eae8e8);
background-image: -ms-linear-gradient(top, #f6f6f6, #eae8e8);
background-image: -o-linear-gradient(top, #f6f6f6, #eae8e8);
background-image: linear-gradient(top, #f6f6f6, #eae8e8);
}
.form-wrapper-01 #search {
max-width: 330px;
width:100%;
height: 20px;
padding: 10px 5px;
float: left;
font: bold 16px 'lucida sans', 'trebuchet MS', 'Tahoma';
border: 1px solid #ccc;
-moz-box-shadow: 0 1px 1px #ddd inset, 0 1px 0 #fff;
-webkit-box-shadow: 0 1px 1px #ddd inset, 0 1px 0 #fff;
box-shadow: 0 1px 1px #ddd inset, 0 1px 0 #fff;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.form-wrapper-01 #search:focus {
outline: 0;
border-color: #aaa;
-moz-box-shadow: 0 1px 1px #bbb inset;
-webkit-box-shadow: 0 1px 1px #bbb inset;
box-shadow: 0 1px 1px #bbb inset;
}
.form-wrapper-01 #search::-webkit-input-placeholder {
color: #999;
font-weight: normal;
font-size:12px;
font-style:italic;
}
.form-wrapper-01 #search:-moz-placeholder {
color: #999;
font-weight: normal;
font-size:12px;
font-style:italic;
}
.form-wrapper-01 #search:-ms-input-placeholder {
color: #999;
font-weight: normal;
font-size:12px;
font-style:italic;
}
.form-wrapper-01 #submit {
float: right;
border: 1px solid #00748f;
height: 42px;
max-width: 100px;
width:100%;
padding: 0;
cursor: pointer;
font: bold 15px Arial, Helvetica;
color: #fafafa;
text-transform: none;
background-color: #0483a0;
background-image: -webkit-gradient(linear, left top, left bottom, from(#31b2c3), to(#0483a0));
background-image: -webkit-linear-gradient(top, #31b2c3, #0483a0);
background-image: -moz-linear-gradient(top, #31b2c3, #0483a0);
background-image: -ms-linear-gradient(top, #31b2c3, #0483a0);
background-image: -o-linear-gradient(top, #31b2c3, #0483a0);
background-image: linear-gradient(top, #31b2c3, #0483a0);
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
text-shadow: 0 1px 0 rgba(0, 0 ,0, .3);
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 0 #fff;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 0 #fff;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset, 0 1px 0 #fff;
}
.form-wrapper-01 #submit:hover,
.form-wrapper-01 #submit:focus {
background-color: #31b2c3;
background-image: -webkit-gradient(linear, left top, left bottom, from(#0483a0), to(#31b2c3));
background-image: -webkit-linear-gradient(top, #0483a0, #31b2c3);
background-image: -moz-linear-gradient(top, #0483a0, #31b2c3);
background-image: -ms-linear-gradient(top, #0483a0, #31b2c3);
background-image: -o-linear-gradient(top, #0483a0, #31b2c3);
background-image: linear-gradient(top, #0483a0, #31b2c3);
}
.form-wrapper-01 #submit:active {
outline: 0;
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
}
.form-wrapper-01 #submit::-moz-focus-inner {
border: 0;
}
here is live example
http://jsfiddle.net/6TUem/
as you can see the problem is with search button which shift itself in next line when you resize the window.i want it to stick with the input [text] field
Why not make something like this?
#media screen and (max-width: 520px) {
.form-wrapper-01 #submit {
float: none;
max-width: none;
margin-top: 1em;
}
.form-wrapper-01 #search {
max-width: none;
width: 100%%;
}
}
(Admittedly, I did change some things such as box-sizing.)
You have to wrap the input in a div and then use some style like this:
.form-wrapper-01 {
background-color: #f3f3f3;
width: 100%;
max-width: 450px;
position: relative;
display: block;
text-align: right;
padding: 10px;
}
#search {
background-color: #ff0000;
position: absolute;
left: 10px;
right: 100px;
}
#search input {
width: 100%;
}
#submit {
width: 80px;
}
See this fiddle: http://jsfiddle.net/6TUem/4/

jQuery click issue with a span styled to look like a button

Context
I've this buttons:
I detect when the user is clicking with jQuery .click().
But it works only if the user clicks on the text ("imdb" / "rottenTomatoes").
If the user clicks on the blue of button, jQuery detects nothing.
You can try on http://promobluray.fr.
Questions
What is the problem?
How to get this to work like a button?
Code
html:
<span class="rating">
<span class="rating-btn imdb active">imdb</span>
<span class="rating-btn rt">rottenTomatoes</span>
</span>​
css:
.rating {
padding: 14px;
}
.rating-btn {
display: inline-block;
margin-top: 24px;
padding: 4px;
position: relative;
font-family: 'Open Sans',sans-serif;
font-size: 12px;
text-decoration: none;
color: white;
cursor: pointer;
background-image: -o-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: -moz-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: -webkit-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: -ms-linear-gradient(bottom,#2CA0CA 0,#08C 100%);
background-image: linear-gradient(bottom,#2CA0CA 0,#08C 100%);
-webkit-box-shadow: inset 0 1px 0 #7fd2f1,0px 6px 0 #156785;
-moz-box-shadow: inset 0 1px 0 #7fd2f1,0px 6px 0 #156785;
box-shadow: inset 0 1px 0 #7fd2f1,0px 6px 0 #156785;
border-radius: 5px;
}
.rating-btn::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;
-webkit-box-shadow: 0 1px 0 #fff;
-moz-box-shadow: 0 1px 0 #fff;
box-shadow: 0 1px 0 #fff;
}
.active {
background: #2CA0CA;
-webkit-box-shadow: inset 0 1px 0 #7fd2f1,inset 0 -1px 0 #156785;
-moz-box-shadow: inset 0 1px 0 #7fd2f1,inset 0 -1px 0 #156785;
box-shadow: inset 0 1px 0 #7fd2f1,inset 0 -1px 0 #156785;
top: 7px;
cursor: default;
}
.imdb {
margin-right: 5px;
}
jquery:
$('.rating-btn').click(function() { ... });
​
You could try to increase the padding of the button so that the <span> matches the dimension of the image, but i think that the best solution is to change your markup and actually use <button>
It's seems to work in the latest versions of FF and IE, but not Chrome, Opera and Safari(win). I would suggest adding display:block; to .rating-btn styles to see what that does.
Alternatively, actually use buttons and style those how you want.
Use parent to attach handler
$('.rating:has(.rating-btn)').click(function() { ... });