I am having trouble getting my submit button to display in line with my inputs in internet explorer. The alignment is fine in safari and firefox but IE is dropping the button down about 5px. Any ideas why this is happening or how i can fix it?
The url is http://www.menslifestyles.com
click subscribe at the top of the page the form will pop in.
The two inputs line up straight but in ie the submit button doesn't align!
-------html-------
<div id="subscribe">
<form id="subscribeform" method="post" action="/maillists/subscribe" accept-charset="utf-8">
<div style="display:none;"><input type="hidden" name="_method" value="POST"></div>
<label for="MaillistName">Name</label><input name="data[Maillist][name]" type="text" maxlength="255" id="MaillistName">
<label for="MaillistEmail">Email</label><input name="data[Maillist][email]" type="text" maxlength="500" id="MaillistEmail">
<input type="submit" value="Submit">X
</form></div>
-----css-------
#subscribe{
width:620px;
position:absolute;
top:25px;
left:50%;
margin-left:-120px;
overflow: auto;
z-index: 1000;
background: #ffffff;
color:#6e6e6e;
font-size: 10px;
text-transform: uppercase;
font-family: Helvetica, Verdana;
}
#subscribe input{
border: 1px solid #e5e5e5;
display: inline;
height: 12px;
color:#cccccc;
width: 215px;
}
#subscribe input[type="button"], #subscribe input[type="submit"]{
clear:both;
padding:3px, 0px;
-webkit-appearance: none;
font-family: Helvetica, Verdana;
background-color:#cccccc;
text-align:center;
color: #3c3c3c;
font-size:10px;
text-transform: uppercase;
border: none;
cursor: pointer;
display: inline;
height:15px;
width:60px;
position:relative;
margin-left:5px;
}
#subscribe form{
margin:0px;
padding:0px;
}
#subscribe label{
display: inline;
font-size: 10px;
}
#subscribe a{
text-decoration: none;
color: #cccccc;
}
#subscribe #closelink{
padding:0 5px;
}
In your css for #subscribe input[type="button"], #subscribe input[type="submit"] try to add vertical-align: top;
You should set padding and margin explicitly, some browsers have different defaults which will mess things up. So margin-left:5px; becomes margin: 0 0 0 3px;
Forms are also just inconsistent generally, you may want to try and absolutely positioning the submit button, in which case give #subscribe position:relative, and the submit button position:absolute; right:0px; top:0px;
In the future you can get around default browser values, and get a more consistent look by setting default values in your stylesheet , see here for a reset stylesheet that you can include. (If you include this now it might throw a few things out)
In this css rule
#subscribe input[type="button"], #subscribe input[type="submit"]
Change
position:relative
to
position:absolute
Should do the trick. Tested in IE 8 and works.
Submit button seem to have different default margin and padding values in different browsers.
I assume this must be in some reset Stylesheet as this is not the only annoying cross browser "default" values discrepancy. When is the web going to standardize this is another subject.
This is how we do it:
#searchForm {
position: relative; // you must keep this
font-weight: normal;
font-family: Arial, Helvetica, sans-serif;
margin-bottom: 30px;
}
input#searchBtn{
padding: 0; // you must keep this
margin: 0; // you must keep this
position: absolute; // you must keep this
left: 203px; // you can change this
top: 2px;
height: 24px;
width: 42px; // you can change this
font-size: 14px;
background: url(http://yourDomain/img/yourPrettySearchIcon.png) buttonface no-repeat 9px 1px;
}
<form id="searchForm" name="mySearchForm" action="myPage.html" method="post">
<input name="searchBtn" value="" id="searchBtn" type="submit"/>
</form>
I noticed very small discrepancies between IE8, Firefox and GChrome but there may be in other browsers.
The form here has its position set to "relative" so that when I set the button's position to absolute, the button position itself relatively to the searchForm.
Related
I have the following code in which I am seeing an inconsistency in styling between the styling of the placeholder text in the email input box and the styling of the content of the options box, this is especially seen in Firefox where the content of the options box appears bold in comparison to the "Email" placeholder text. I'm wondering if it is possible to get a more consistent look between the two whilst keeping the same font family and font size.
html:
<input type="email" name="email" placeholder="Email">
<br />
<select>
<option selected>Option 1</option>
</select>
css:
input[type=email] {
width: 320px;
height: 20px;
background-color: #E9F2F9;
border: none;
margin-top: 20px;
margin-left: 20px;
padding-top: 8px;
padding-bottom: 12px;
padding-left: 9px;
position:relative;
}
select {
font-size: 15px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
line-height: 20px;
letter-spacing: -0.02px;
width:329px;
height:40px;
padding-left:9px;
padding-top:8px;
padding-bottom:12px;
background: #E9F2F9;
color:#666666;
border:none;
display: inline-block;
cursor:pointer;
position: relative;
margin-left: 20px;
margin-top: 20px;
}
If you want to adjust the placeholder styling you can use the pesudo-class selector ::placeholder in addition to the input selector input[type=email].
If you want to adjust the option styling you can use the option.
This way you can synchronize the styling of the elements:
option, input[type=email]::placeholder {
font-family: Helvetica;
text-transform: Uppercase;
font-size: 1em;
background-color:yellow;
}
Of course you can use whatever properties you wish. This will allow you to override any browser defaults which might affect the look differently.
Here is some more info about pseudo-classes:
https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
They can be extremely useful so going over some of them to at least get a sense of what's available is highly recommended.
For some more help with cross-browser quirks i also recommend checking out the normalize library:
http://nicolasgallagher.com/about-normalize-css/
EDIT:
select, option, input[type=email]::placeholder {
color: black;
font-family: Helvetica;
font-size: 16px;
font-weight: 500;
text-transform: capitalize;
}
As you can see from this image of my site:
https://www.flickr.com/photos/77598212#N03/33735427334/in/dateposted-public/
My button is crammed right underneath the randomly generated text. Instead, I'd like to lower it.
But additionally, I'm trying to keep it completely "anchored" to the page, because right now when I click the button, a random image generates, but that image is moving the button vertically depending on the size of the image. Not good.
Instead, I'd like that button to remain in the same position, always.
Any thoughts/help would be appreciated. I'm still quite new to all this. Thank you. -Wilson
link to the actual website http://www.wilsonschlamme.com/test4.html
css:
*It's pretty simple. First two elements here are controlling centering the page. The rest are self explanatory, showtext refers to the random text generator.
*{
margin:0;
padding:0;
}
body{
text-align:center; /*For IE6 Shenanigans*/
}
button {
color: #900;
font-weight: bold;
font-size: 150%;
text-transform: uppercase;
}
h1{
margin-top:20px;
font-size: 250%;
overflow:hidden; /* older browsers */
font-family: hobeaux-rococeaux-sherman, sans-serif;
}
img {
max-width:600px;
max-height:440px;
box-shadow: 1px 5px 5px grey;
border-style: groove;
border-width: 1px;
margin-top:20px;
}
#ShowText{
overflow:hidden; /* older browsers */
word-wrap: break-word;
padding-top: 100px;
max-width: 1000px;
font-size: 25px;
font-family: vendetta, serif;
line-height: 25px;
margin: 0 auto;
}
Use:
#buttonfun {
margin-top: 20px;
}
Wrap the img with a div:
<div class="image-wrapper">
<img src="images/297.jpg" />
</div>
and add the CSS:
.image-wrapper {
height: 440px;
}
I'm trying to override the default form styling for two form elements so that the text box and button are both the same height and are side by side so that it looks like they are one element.
In some browsers it looks fine but in some they are a pixel or two off vertically.
Here is a jsfiddle demo. Opera and Firefox on OS X are giving me issues.
http://jsfiddle.net/QS3ec/6/
*, *:before, *:after {-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;}
input[type="text"] {
background-color: #fafafa;
padding: 7px;
font-family: helvetica, arial, sans-serif;
font-size: 1.2em;
margin-bottom: 20px;
display: block;
border: solid 2px #bbb;
color: #6f6f6f;
}
input[type="submit"] {
background-color: #fafafa;
font-family: helvetica, arial, sans-serif;
font-size: 1.0em;
font-weight:bold;
padding: 7px;
color: #6f6f6f;
}
input[type="submit"]:hover {
background-color: #ff379f;
color: #fafafa;
}
#subscription-email-text-field {
display:inline-block;
font-size:0.9em;
font-weight:400;
border:0;
width:250px;
height:32px;
margin:0;
}
#subscribe-button {
display:inline-block;
border-width:0px 0px 0px 1px;
margin:0;
height:32px;
}
<div style="background-color:black; padding:20px;">
<form>
<input type="text" id="subscription-email-text-field" name="email" placeholder="Enter Email for Newsletter"><!--
--><input type="submit" id="subscribe-button" value="subscribe">
</form>
</div>
One simple fix is to modify the following CSS rule:
#subscription-email-text-field {
vertical-align: top;
display:inline-block;
font-size:0.9em;
font-weight:400;
border:0;
width:250px;
height:32px;
margin:0;
}
Adding vertical-align: top takes care of the baseline alignment.
See demo at: http://jsfiddle.net/audetwebdesign/EmAnr/
Footnote:
To add the left border on the button element, remember to add the border styling,
which can be done as follows:
#subscribe-button {
display:inline-block;
border: 1px solid black;
border-width:0px 0px 0px 1px;
margin:0;
height:32px;
}
All I've done is increased the height of the submit box:
height: 46px;
http://jsfiddle.net/QS3ec/9/
This is really tough. I've Tested in Safari, Firefox, Opera and Chrome on Mountain Lion so this may not be the right solution.
I believe the problem is that the inputs are replacement elements that have been rendered by the browser using non-CSS mechanisms so styling may not apply as you would expect. I had a similar question in the past that shed some light on this sort of thing. There always seems to be strange behavior when trying to style old UI components, buttons, inputs, etc.
Display Table Cell inconsistency.
Problem is the padding you have given to the text box. On certain
browsers padding has only horizontal effect on input type = button or submit.
// fix
add 'box-sizing: content-box' rule to the input[type='submit'] { } closure.
This will do on certain browsers as only few have implemented it.
As a workaround set height of the submit button to
"height of text-box + ( 2 * padding given to text-box')
inorder to account for the missing vertical padding.
This is the best way to achieve your goal (cross-browser).
eg: height of your text-box = 32px. so height of the button = 32 + 2 * 7 = 46px
This issue has been driving me crazy all morning. I've been trying to get my input field with a custom background to align correctly in IE. I read other questions that said line-height will fix it, but that hasn't been working.
It looks fine in chorme/safari/etc but in IE8 the text is stuck to the top of the input area. (Stack won't let me post images yet). My CSS is:
#email {
background: url('BACKGROUND IMAGE') left top no-repeat;
background-size: 273px 38px;
width: 273px;
height: 38px;
line-height: 38px;
border: 0;
margin: 0 0 5px;
font: bold 12px arial, helvetica, sans-serif;
color: #777;
padding:0 8px;
outline: none;
float:left;
}
and the HTML:
<input id="email" type="text" name="email" size="14" value="your email address" onfocus="if(this.value=='your email address') {this.style.color='#333'; this.value='';}" onblur="if(this.value== '') {this.style.color='#808080'; this.value='your email address';}" />
Any ideas on how to get my input text to vertically center in IE 8 and lower?
This should be easy to fix. The line-height property is important, but it seems to get lost in IE8 when you're using the shorthand font property. Try adding in the line-height to the shorthand font property, and removing the line-height that you have declared separately.
#email {
background: url('BACKGROUND IMAGE') left top no-repeat;
background-size: 273px 38px;
width: 273px;
height: 38px;
border: 0;
margin: 0 0 5px;
font: bold 12px/38px arial, helvetica, sans-serif;
color: #777;
padding:0 8px;
outline: none;
float:left;
border:1px solid #999;
}
Here's a jsFiddle example for you (border added just to show how it's aligning).
Here is my code, which works perfectly in all but ie! The active simply does not fire
a.Button span {
background: transparent url('images/form_sprite.png') no-repeat 0 0;
display: block;
height:45px;
line-height: 30px;
padding: 7px 0 5px 20px;
color: #fff;
background-position: 0 -44px;
}
a.Button {
background: transparent url('images/form_sprite.png') no-repeat top right;
display: block;
float: left;
height: 45px;
margin-right: 6px;
padding-right: 27px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
}
a.Button:hover span {
background-position: 0 -136px;
}
a.Button:hover {
background-position: right -90px;
}
a.Button:active span {
background-position: 0 -225px;
}
a.Button:active {
background-position: right -181px;
}
This is the html:
<div class="clearbutton"> <a class="Button" href="#"><span>Button text</span></a> </div>
Any ideas please?
try changing a.Button:active to a.Button span:active in your css. That seems to be firing the :active css and still works in chrome for me.
Yep, the :active psuedo-class only fires in IE when the user is clicking directly on that object. In this case, the link. If you're clicking on a child object (the span), the link's active event won't fire.
You can, as Aninemity said, apply the style to span:active (the proper way to do this). But in IE6/7, :active fires only for links. If you need IE6/7 support, you'll have to find some way to get rid of the span.