Styling a submit button using CSS and images - html

i want to make and style submit buttons i.e.
input type="submit" style="buttonClass">
using CSS and provided images, that works on both hover as well as normal state, however i'm unable to reach the desired output.
I created the buttons using anchor tags and span which are perfect but i want the same look and feel for submit buttons also.
PS: i cannot use the moz and webtooolkit of css3 as my target browser will be IE7 and IE 8, and further i have to use the client provided images only.Is there any way around for submit button<input type="submit"> to reach the desired output just similar to the buttons as created using the anchor buttons <a><span></span></a>?
HTML AS IS
<a class="buttonImage" href="javascript:blankCheck('Approve');"><span> <bean:message key="button.common.submit"/> </span></a>
HTML TO BE
<input type="submit" class="buttonImage">
CSS AS IS for buttons using anchor
.buttonImage span {
background: url('common/images/LeftButton.png') no-repeat 0 0; display: block;
line-height: 14px; padding: 7px 0 5px 8px; color: #1b1d60;
}
.buttonImage
{
background: url('common/images/RightButton.png') no-repeat top right;
display: block; float: left; height: 26px; margin-right: 6px;
padding-right: 7px; text-decoration: none; font-family: Arial, Helvetica, sans-serif;
font-size:12px; font-weight:bold;
}
.buttonImage:hover span {
background-position: 0 -26px; color: #fff;
}
.buttonImage:hover {
background-position: right -26px;
}

Live Demo
Hi now change to some properties your css stylesheet or add two div in your anchor tag
as like this
Please check to this
Css
.buttonImage{
display:inline-block;
vertical-align:top;
text-decoration:none;
}
.buttonImage .left_img {
background: url('http://i.stack.imgur.com/634e1.png') no-repeat 0 0;
float:left; line-height: 15px; padding: 7px 0 5px 8px; color: #1b1d60;
}
.right_img{
background: url('http://i.stack.imgur.com/SyeSO.png') no-repeat 0 0;
float:left; height: 27px;
width:7px;
}
.buttonImage:hover .left_img, .buttonImage:hover .right_img{
background-position:0 -26px;
color:#fff;
}
HTML
<a class="buttonImage" href="javascript:blankCheck('Approve');">
<span class="left_img"> <bean:message key="button.common.submit"/>Hello this is coding
</span>
<span class="right_img"></span>
</a>
Demo

Related

CSS not working on 2 DIV tags when I add display: inline;

So I am creating a code compiler with two buttons:
RUN and DOWNLOAD. But instead of using <button> tags, I use <div> tags so that I can have a more variety of CSS styles for my buttons. But the problem is, when I try to make the second button by copying and pasting the same code from the RUN button, the DOWNLOAD button is underneath the RUN button when I needed them on the same line.
So, I added the display: inline; style but that just messed up everything and the styles for the div didn't work. The only styles that worked were the styles for the text in the div buttons and that centered the text to the middle of the page.
Here is the code:
.dbutton,
.button {
background-color: red;
margin-right: 300px;
box-shadow: 0px 0px 5px gray;
font-size: 20px;
color: blue;
text-align: center;
width: 100px;
height: 50px;
}
.btn-text {
margin-top: 10px;
padding-top: 12px;
}
.dbtn-text {
margin-top: 10px;
padding-top: 12px;
}
.dbutton:hover,
.button:hover {
background-color: white;
-webkit-user-select: none;
}
.dbutton:active,
.button:active {
background-color: #00ad08;
}
div {
display: inline;
}
<div class="button">
<p class="btn-text">
Run >>
</p>
</div>
<div class="dbutton">
<p class="dbtn-text">
Download ↓
</p>
</div>
If you want the full code, here is the link.
JSFIDDLE
The two divs are not styling and the text in the buttons are placed in the middle of the page. I need the two divs to be beside each other and the for the style to work. Please help me!
.btn-bar {
position:relative
/* ... */
}
.btn {
float:left;
background:red;
width:7em;
padding:11px 3px;
margin:3px;
text-align:center;
text-transform:uppercase;
box-shadow:0 0 3px 0 #000;
}
<div class="btn-bar">
<div class="btn">run</div>
<div class="btn">compile</div>
</div>

Horizontal li - align element vertically

I'm using a <ul> with css display: inline; set to use as a toolbar/menu at the top of my page like this:
As you can see, the text vertically aligns perfectly, however the img on the left is too high, and the input box on the right is slightly low. I'm struggling to move them so they are perfectly vertically aligned.
Below is my CSS:
.mynav {
font-weight: 300;
border: 1px solid #ccc;
border-width: 1px 0;
list-style: none;
margin: 0;
padding: 0;
text-align: center;
background-color: #0067b1;
}
.mynav li {
display: inline;
align-items: center;
vertical-align:middle;
line-height:35px;
}
.mynav a {
color: white;
display: inline-block;
padding: 15px;
font-size: 14pt;
text-decoration: none;
}
.mynav input {
margin-left: 25px;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
font-style: italic;
-moz-border-radius: 10px;
border-radius: 10px;
border: none;
padding: 5px;
width: 200px;
height: 25px;
margin-top: 0px;
}
.mynav i
{
font-weight: 300;
color: white;
font-size: 24px;
margin-left: 15px;
}
And my HTML (if needed):
<ul class="mynav">
<li><img src="http://www.advancegroupholdings.com.au/my_logo_nav.png" style="width: 100px; height:25px; padding-right:25px;" /></li>
<li>My Jobs</li>
<li>Obtain a Quote</li>
<li>Submit New Instruction</li>
<li>Settings</li>
<li>Help</li>
<li><input type="text" placeholder="Enter Your Ref or Job Number"/><i class="fa fa-search"></i></li>
</ul>
As for the input box, it has a padding of 5 which I have tried to remove with no luck. I have also set margin-top: 0px on the input, still no luck.
As for the logo, I'm also quite stumped. I've tried adding margin-top: 5px, but it's not working.
I also have found both these questions on StackOverflow:
<ul> horizontal nav bar... vertically-align element
css - verticaly align horizontal li
The first had no effect and the second wanted to change the CSS to display: flex, which for me gets rid of the horizontal bar, doesn't it?
Can anyone help me get the logo and the input box (and the magnifying glass) vertically centered? Thank you in advance!
Plunker here
I created a small bootstrap example for what you require. Different to what you have but give the required output more or less. Hopefully you can continue from here if this solution works for you.
HTML
<div class="col-md-2"><img src="http://www.advancegroupholdings.com.au/my_logo_nav.png" /></div>
<div class="col-md-1">My Jobs</div>
<div class="col-md-2">Obtain a Quote</div>
<div class="col-md-2">Submit a New Instruction</div>
<div class="col-md-1">Settings</div>
<div class="col-md-1">Help</div>
<div class="col-md-3"><input class="inputHeight" type="text" placeholder="Enter Your Ref or Job Number"/><i class="fa fa-search"></i></div>
</div>
</div>
CSS
.navbar {
width:80%;
font-weight: 300;
border: 1px solid #ccc;
border-width: 1px 0;
margin: 0;
padding: 0;
text-align: center;
background-color: #0067b1;
vertical-align:middle;
line-height:50px;
}
.inputHeight {
margin-left: 25px;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
font-style: italic;
-moz-border-radius: 10px;
border-radius: 10px;
border: none;
padding: 5px;
width: 200px;
height: 25px;
margin-top: 0px;
}
Plunker Example
Adding next two rules to your image will center it correctly.
display: inline-block;
vertical-align: sub; /* or text-bottom */
As for the input , it looks correctly centered to me.
In your specific example it's enough to add vertical-align:middle; to <img> and to <a>, <i> elements! Also I'd recommend to have <li> elements as inline-block, not inline for more flexibility.
In general case, to align vertically the image height must be equal as
other element's line-height in the line and vertical-align:middle has to be set.
If image height is 25px then set:
.mynav li, .mynav i {
vertical-align:middle;
line-height:25px;
}
img {
vertical-align:middle;
height: 25px;
line-height:25px;
}
Here you go: https://plnkr.co/edit/Xf3uvvjuqykQMjnhVxes?p=preview

adjusting background color gradient of a submit button with css

Hi i want to style an input submit button which has a background as given in the attached image.The back ground image was provided, but im not sure how to implement it in the submit button so instead of using that image i tried using the css 3 color gradient properties to style the button,however, i cant get the desired color output.Any help is welcome.
CSS code so far.
.button {
-moz-border-radius: 18px;
-moz-box-shadow: #fffff 0px 0px 11px;
-webkit-border-radius: 18px;
-webkit-box-shadow: #6E7849 0 0 10px;
background-color: #fefefefe;
background-image: -moz-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -ms-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -o-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: -webkit-linear-gradient(24deg, #d8d8d8, #fefefefe);
background-image: linear-gradient(24deg, #d8d8d8, #fefefefe);
border-radius: 18px;
border: 1px solid #888888;
box-shadow: #fffff 0px 0px 11px;
color: #000000;
display: inline-block;
font-size: 3em;
margin: auto;
padding: 4px;
text-decoration: none;
}
Use the image. Matching the gradient fully to the image is an unnecessary pain:
.button {
display:block;
width:50px; //use actual image width
height:50px; // use actual image height
background:url(../img/button.png); //image file path
}
.button:hover {
background:url(../img/button_hover.png);
}
To use an image as the input is very simple:
<input type="image"src="/images/submit.gif" />
Finally i found the way to make this button using sliding door technique.However still in jeopardy to style it in disabled state.
This link helped me alot http://www.springload.co.nz/love-the-web/dynamic-submit-buttons
css
div.submit_button {
background: transparent url('common/images/bg-submit2.png') no-repeat 0 0;
display: block;
float: left;
height: 27px; /* total height of the button */
padding-left: 15px; /* end width */
}
span.submit_button_end {
background: #fff url('common/images/bg-submit2.png') no-repeat 100% 0; /* used a sprite image */
display: block;
float: left;
font-weight: normal;
height: 27px; /* total height of the button */
}
input.submit_input {
font-size: 13px;
font-weight:bold;
background: none;
border: none;
padding: 0 0 2px 15px; /* end width */
color: #1b1d60;
cursor: pointer;
position: relative;
height: 25px;
line-height: 25px;
left: -15px;
margin-right: -15px;
padding-right: 15px;
}
input.submit_input:hover {color: #fff;}
div.submit_button:hover {background-position: 0 100%;}
div.submit_button:hover span.submit_button_end {background-position: 100% 100%;}
HTML
<div class='submit_button'>
<span class='submit_button_end'>
<input class='submit_input' type='submit' value='Submit button' tabindex='#' />
</span>
</div>

Can't add image to text on Bootstrap button

I'm using Bootstrap and sometimes it is hard to overwrite it.I want to add some picture to my button, near text. So I added background-image, but it doesn't apply.
Here is css for my button:
.submit .report{
font-size: 18px;
text-shadow: none;
font-weight: bold;
padding: 5px;
width:300px;
color:white;
filter:alpha(opacity=100);
background: #628d28;
background-image:url('../images/picture.png') no-repeat;
}
BUT Firebug say, that my element has next CSS:
.submit .report{
font-size: 18px;
text-shadow: none;
font-weight: bold;
padding: 5px;
width:300px;
color:white;
filter:alpha(opacity=100);
background-image: none repeat color(98,141,40);
}
Why I can't add background image ?
You define wrong background properties. Write like this:
.submit .report{
background-color: #628d28;
background-image:url('../images/picture.png');
background-repeat:no-repeat;
}
OR
.submit .report{
background: #628d28 url('../images/picture.png') no-repeat;
}

Link not working inside of <li>

I looked at the answers to similar questions, but none provided the help I need; I'm still getting unresponsive links !?
To be clearer, by unresponsive links I mean the link does not work; they style exactly as expected.
Here's the CSS:
#nav3 { padding: 0; margin:15px 15px 0; height:29px; background-repeat: repeat; background-position: left top; }
.ddcolortabs { padding: 0; width: 100%; }
.ddcolortabs ul { font: normal 13px Arial, Verdana, sans-serif; margin:0 0 0; padding:0; list-style:none; }
.ddcolortabs li { display:inline; margin:0 2px 0 0; padding:0; }
.ddcolortabs a { float:left; color: #4963AE; background: #B9D6E5 url(../../content/themes/wd/images/tabs/color_tabs_left.png) no-repeat left top; margin:0 6px 0 0; padding:0 0 1px 3px; text-decoration:none; letter-spacing: 1px; font-weight: bold; }
.ddcolortabs a.selected { background: #98a5d3 url(../../content/themes/wd/images/tabs/color_tabs_left.png) no-repeat left top; color: #FFF; }
.ddcolortabs a span { float:left; display:block; padding: 8px 20px 6px 19px; background: transparent url(../../content/themes/wd/images/tabs/color_tabs_right.png) no-repeat right top; }
And here's the html:
<div id="nav3">
<div id="colortab2" class="ddcolortabs">
<ul style="margin-left:10px;">
<li><span>Most Active</span> </li>
<li><span>Most Popular</span></li>
<li><span>Most Recent</span></li>
<li><span>Browse Categories</span></li>
</ul>
</div>
</div>
My bad, higher in the markup I had a div styled with z-index: -1
I just ran into this issue. I solved it by including the full link for the page plus the anchor.
Click here
Annoying issue to have. It was working fine locally prior to making this change. I am not sure if the web host's server plays a part in this somehow?