Style link as submit button - css

I have a link and a submit button styled with the same .button class. Is there an easy way to make them look exactly the same (to have a same height)?
body .button {
text-align: center;
line-height: 15px;
background: #3333CC;
border-color: #5033CC;
border-radius: 4px;
color: #fff;
font-size: 11px;
border: 1px solid;
padding: 4px 7px 4px 7px;
cursor: pointer;
min-width: 90px;
text-decoration: none;
display: inline-block;
}
<form>
<a class="button" href="http://www.example.org">Link as button</a>
<input class="button" type="submit" value="button as button"/>
</form>
EDIT: I just found out that they look the same in Google Chrome, but not in Firefox.

In this example, they do have the same height (25pixels). You can always set a height in the CSS.
One thing you missed is changing the font-family.
In this example I've added one just to Helvetica, but that will make them more similar.
You can set box-sizing:border-box, set a solid height (25px in this example) and then change display:inline-block; to float:left;
body .button {
text-align: center;
line-height: 15px;
background: #3333CC;
border-color: #5033CC;
border-radius: 4px;
color: #fff;
font-size: 11px;
border: 1px solid;
padding: 4px 7px 4px 7px;
cursor: pointer;
min-width: 90px;
text-decoration: none;
float:left;
font-family:'Helvetica';
box-sizing:border-box;
height:25px;
}
<form>
<a class="button" href="http://www.example.org">Link as button</a>
<input class="button" type="submit" value="button as button"/>
</form>

Related

submit button does not work after using display inline

I don't know what else to do. I am a newbie and doing what I thought was
simple coding. I have tried everything including display:inline and
display:inline important;". I am trying to put the submit button on the
same line with the same style attributes (blue, white words, etc.).
Please help!
<form action="/action_page.php">
<input type="textarea" name="firstname" placeholder="Enter your address
to determine if we buy in your neighborhood" style=
"border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top: 1px solid #d6d4d4;
border-right: 1px solid #d6d4d4;
border-bottom: 1px solid #d6d4d4;
border-left: 1px solid #d6d4d4;
height: 52px;
width: 618px;
padding-top: 15px;
padding-right: 15px;
padding-bottom: 15px;
padding-left: 15px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
margin-left: 5px;
color: #161616;
line-height: 1.1;
box-sizing: border-box;
font-family: open sans;
font-weight: 400;
text-align: left;
text-align-last: left;
font-size: 16px;
background-color: #fff;
background-image: none;
overflow: hidden;
box-shadow: 0 0 0 rgba(0,0,0,.5);">
<input type="submit" value="Get Started" style="font-weight: 400; line-
height: 3.1;
font-size: 13px;
color: #ffffff;
background-color: #12208e;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top: 0;
border-right: 0;
border-bottom: 0;
border-left: 0;
height: 50px;
width: 160px;
padding-top: 0;
padding-right: 14px;
padding-bottom: 0;
padding-left: 14px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 5px;
margin-left: 5px;
color: #fff;
line-height: 1;
box-sizing: border-box;
font-family: open sans;
font-weight: 700;
text-align: center;
text-align-last: center;
font-size: 20px;
background-color: #12208e;
background-image: none;
overflow: hidden;
text-shadow: 1px 1px 1px #000;">
</form>
There are quite a few things that are causing errors with your code. First of all, to get your desired layout add in a div that wraps around the two input elements like so:
<div class="form-row">
<input type="textarea" name="firstname" placeholder="Enter your address to determine if we buy in your neighborhood" class="name-input">
<input type="submit" value="Get Started" class="btn-submit">
</div>
Apply these styles to that div to make the two input elements appear "on one-line":
.form-row {
display: flex;
flex-direction: row;
width: 100%;
font-weight: 400;
}
You also had a spelling mistake in the styles for your button, where you had line- height: 3.1;, however I removed that line as you were overriding it with another line-height rule further down.
html {
font-family: open sans;
}
.form-row {
display: flex;
flex-direction: row;
width: 100%;
font-weight: 400;
}
.name-input {
border-radius: 4px;
border: 1px solid #d6d4d4;
height: 52px;
width: 618px;
padding: 15px;
margin: 5px;
color: #161616;
line-height: 1.1;
box-sizing: border-box;
font-family: open sans;
text-align: left;
font-size: 16px;
background-color: #fff;
box-shadow: 0 0 0 rgba(0, 0, 0, .5);
}
.btn-submit {
color: #ffffff;
background-color: #12208e;
border-radius: 5px;
border: 0;
height: 50px;
width: 160px;
padding: 0 14px;
margin: 5px;
color: #fff;
line-height: 1;
box-sizing: border-box;
font-weight: 700;
text-align: center;
font-size: 20px;
text-shadow: 1px 1px 1px #000;
}
<form action="/action_page.php">
<div class="form-row">
<input type="textarea" name="firstname" placeholder="Enter your address to determine if we buy in your neighborhood" class="name-input">
<input type="submit" value="Get Started" class="btn-submit">
</div>
</form>
Note: Since you are setting a fixed width on those two elements, they won't fit on one line on very small screens, or if other elements are added to it.
I greatly recommend splitting your CSS into a separate CSS file like in this snippet. It will allow you to better see what is going on. Also if you use a decent IDE (code editor) it will pick up these errors for you as well.
Here are some resources you can use to learn more about CSS and HTML. Good luck!

How to work with hyperlink and submit buttons together in Foundation Zurb CSS

I really like the Option Button found in the ZURB building block library here: http://zurb.com/building-blocks/option-button
However, I am almost always working with 1 x normal hyperlink button and a submit button. I'm finding this is causing me headaches wherever I try to have neat rows of buttons that should look the same. What additional CSS would get this 'Option Button' to work as desired when working with an input submit class ?
My HTML is pretty straightforward and looks like this:
<form name="article_selection" action="single-article-view.php" method="post">
<div class="row">
<div class="medium-6 columns">
<div class="wrapper">
<label>READ MORE</label>
Read on another website
<input type="hidden" value="<?php echo $article_ID; ?>" name="article_ID" />
<input type="submit" class="inside" name="<?php echo $article_ID; ?>" value="Read on this website" />
</div>
</div>
</div>
</form>
In this scenario the 2nd half of the option button is malformed.
I can't update an image to display due to reputation restrictions (seriously?)
<img src="http://i96.photobucket.com/albums/l185/indoanalytics/Button_Problem_zpszhgpvzbt.png" border="0" alt=" photo Button_Problem_zpszhgpvzbt.png"/>
The CSS as per the building blocks option button (linked to above) is:
.wrapper {
overflow: hidden;
display: inline-block;
border: 2px solid #008cba;
border-radius: 999px;
text-align: center;
width: 100%;
background: #fff;
margin-top: 50px;
}
.wrapper:hover {
border: none;
background-color: #008cba;
transition: background-color 0.3s ease;
}
.wrapper:hover .inside {
display: block;
font-size: 16px;
padding: 22px;
float: left;
}
.wrapper:hover .inside:hover {
transition: background-color 0.3s ease;
background-color: rgba(0, 0, 0, 0.1);
}
.wrapper:hover label {
display: none;
}
.wrapper .inside {
display: none;
color: #fff;
width: 50%;
z-index: 9999;
}
.wrapper label {
padding: 16px;
color: #008cba;
font-size: 16px;
font-weight: bold;
}
Update: I also have separate button stylings before the above in the my CSS which may be causing the problem.
.topic-button {
border-style: solid;
border-width: 1px;
font-family: inherit;
font-weight: bold;
line-height: 1;
position: relative;
text-decoration: none;
text-align: center;
-webkit-border-radius: 3px;
border-radius: 3px;
background: #009fd9;
color: #fff;
box-shadow: rgba(255, 255, 255, .4) 0 1px 0 inset;
border-color: #008cbf;
font-size: 12px;
padding: 5px 6px;
margin-top: 2px;
cursor: pointer;
}
.menu-topic-button {
width:99%;
background: #444444;
border:none;
font-family: inherit;
font-weight: bold;
line-height: 1;
position: relative;
text-decoration: none;
text-align: center;
color: white;
font-size: 14px;
padding: 2px;
margin-top: 2px;
cursor: pointer;
}
I have attempted applying CSS from the above to:
.wrapper button[type="submit"] {}
.wrapper input[type="submit"] {}
For both I have copied the .inline CSS from the zurb building blocks as well as tried resetting CSS values back to zero in both, but no luck.
Any help greatly appreciated.

Form input, when focused, causes submit button to move slightly

thanks for the help, I bet this is an easy fix.
I've applied a custom :focus to my input which removes the default outline (glow) and adds a box shadow and border. The only problem is that when the input field is focused, because of the border and box shadow, the submit button, which rests to the right of the input, jumps to the right about a pixel or two. Very annoying.
JSFiddle: http://jsfiddle.net/D3k3B/
<form action="#" method="get">
<input type="text" name="email" placeholder="Your email">
<input type="Submit" name="submit" value="Go">
</form>
form {
position: absolute;
bottom: 20%;
width: 400px;
left: 50%;
margin-left: -125px;
}
input[name="email"] {
font-family: "Prosto One";
width: 200px;
height: 25px;
font-size: 14px;
background-color: rgba(0,0,0,.4);
border: none;
border-radius: 10px;
color: white;
}
input:focus {
outline: none;
border: 1px solid yellow;
box-shadow: 0px 0px 10px yellow;
}
input[name="submit"] {
margin: -5px;
width: 50px;
}
Thanks!
set border 1px solid transparent to input[name="email"]
input[name="email"] {
font-family: "Prosto One";
width: 200px;
height: 25px;
font-size: 14px;
background-color: rgba(0,0,0,.4);
border: 1px solid transparent;
border-radius: 10px;
color: white;
}
You need to match your border css with a transparent value so they don't move when applied
input[name="email"] {
font-family: "Prosto One";
border: 1px solid transparent;
width: 200px;
height: 25px;
font-size: 14px;
background-color: rgba(0,0,0,.4);
border-radius: 10px;
color: white;
}
working example:
http://jsfiddle.net/whiteb0x/D3k3B/3/

Submit button not accepting css styling

I have a submit button in a form that isn't taking on all the style I have set for it. I want the submit button to look the same as a "next section button I have, but it looks different
Here's some relevant HTML:
<form>
Next Section >><br/>
<input type="submit" name="submit" value="Submit Application" id="submit" />
</form>
And here's the CSS:
.btn, #submit {
margin-top: 20px;
background-color: #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
display: inline-block;
color: #fff;
font-family: 'Oswald';
font-size: 20px;
padding: 12px 24px;
text-decoration: none;
cursor: poiner;
float: right;
}
.btn:hover, #submit:hover {
cursor: pointer;
box-shadow: 0px 0px 1px #777;
}
And here's a JS Fiddle which shows the output differences: JS Fiddle
Use this CSS on the submit button.
#submit {
border: none;
}

Position elements on a form using CSS

I need to align labels and inputs of my form using CSS. The result should be something like this (I hope this simple scheme is clear):
Label1: ______
Labellll2: ______
Button
So, my HTML and CSS look as follows. The problem is that labels are placed on top of inputs, and also the button is on the right side instead of a bottom.
<form width="200px" name="optform" method="post" action="#">
<div class = "boxx">
<label for="param1">Param1:</label>
<input type="text" class="input-text" value="5" size="11" maxlength="11" name="param1" id="param1">
<label for="param2">Param1:</label>
<input type="text" class="input-text" value="5" size="11" maxlength="11" name="param2" id="param2">
</div>
<div class="buttons">
<a href="#">
<img src="images/opt.png" alt=""/> Run
</a>
</div>
div.boxx {
width: 500px;
}
div.boxx .input-text{
border:1px solid #A9C7F5;
color: #00557F;
font: 12px Arial;
float:left;
width:66%;
margin:0 0 0.5em 0.25em;
}
div.boxx label{
display:block;
font: 13px Arial;
color:#00557F;
width:33%;
float:left;
text-align:left;
padding-right: 8px;
}
.buttons a, .buttons button {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DFF4FF;
border-color: #EEEEEE #DEDEDE #DEDEDE #EEEEEE;
border-style: solid;
border-width: 1px;
color: #565656;
cursor: pointer;
font-family: Verdana,arial,sans-serif;
font-size: 11px;
font-weight: bold;
line-height: 130%;
margin: 10px 10px 0 0;
padding: 4px 10px 3px 7px;
text-decoration: none;
}
.buttons button {
overflow: visible;
padding: 4px 10px 3px 7px;
width: auto;
}
The label needs to be
display:inline-block;
and the width is too large of either your label or input boxes. Padding and margins will cause problems with percentage widths because they are not taken into account.
Here is the updated css
div.boxx {
width: 500px;
}
div.boxx .input-text{
border:1px solid #A9C7F5;
color: #00557F;
font: 12px Arial;
width:60%;
margin:0 0 0.5em 0.25em;
}
div.boxx label{
display:block;
font: 13px Arial;
color:#00557F;
width:33%;
float:left;
text-align:left;
padding-right: 8px;
}
.buttons a, .buttons button {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DFF4FF;
border-color: #EEEEEE #DEDEDE #DEDEDE #EEEEEE;
border-style: solid;
border-width: 1px;
color: #565656;
cursor: pointer;
font-family: Verdana,arial,sans-serif;
font-size: 11px;
font-weight: bold;
line-height: 130%;
margin: 10px 10px 0 0;
padding: 4px 10px 3px 7px;
text-decoration: none;
}
.buttons button {
overflow: visible;
padding: 4px 10px 3px 7px;
width: auto;
}
I know modern CSS people hate tables, but in this case (and with many alignment issues with divs) I recomment a nice little table.
<table>
<tr>
<td>Label1: </td><td><input type="text" /></td>
</tr><tr>
<td>Label2: </td><td><input type="text" /></td>
</tr><tr>
<td>Label3: </td><td><input type="text" /></td>
</tr>
</table>
<input type="button" />
Try something like this http://jsfiddle.net/mmyxD/
Is there a reason for all the margins/padding? Your width's are forcing the elements onto new lines.
You can also use divs and spans. Something like this:
<form action="">
<div class="row"><span class="label">label1:</span><span class="formw"><input type="text" size="25"></span></div>
<div class="row"><span class="label">label2:</span><span class="formw"><input type="text" size="25"></span></div>
<div class="spacer"> </div>
</form>
and css:
div.row {
clear: both;
padding-top: 10px;
}
div.row span.label {
float: left;
width: 33%;
text-align: left;
}
div.row span.formw input{
width: 100%;
}
div.row span.formw {
float: right;
width: 66%;
text-align: left;
}

Resources