:active being ignored by IE [duplicate] - html

This question already has answers here:
:active css selector not working for IE8 and IE9
(2 answers)
Closed 8 years ago.
I'm making custom buttons with images and then using a div to align the numbers where I want them.
This method is working in every browser but IE. The text centers on the buttons but it is floating to the top. When I click on the button it completely ignores the :active for the button so all that is happening is the .numKeypad:active is working but the button does not.
What to change to make it work in IE? This is the part of my code I think is relevant:
HTML
<div id="btn1" class="btnKeypad" onclick="input(1);">
<div id="num1" class="numKeypad">1</div>
</div>
CSS
#btn1 {
background-image: url(../images/btnUp.png);
cursor:pointer;
left:129px;
top:63px;
}
#btn1:active {
background-image: url(../images/btnDown.png);
left:129px;
top:63px;
}
.numKeypad {
bottom:2px;
font-size:20pt;
position:relative;
text-align:center;
font-family: 'Old Standard TT', serif;
}
.numKeypad:active {
bottom:0px;
font-size:18pt;
position:relative;
text-align:center;
font-family: 'Old Standard TT', serif;
}

These threads might help you out:
How to make :active state work in IE?
:active css selector not working for IE8 and IE9
<a> with an inner <span> not triggering :active state in IE 8
http://msdn.microsoft.com/en-us/library/ie/cc848864%28v=vs.85%29.aspx
A tip regarding the CSS. This should do the exact same job without having unnecessary extra lines of code.
#btn1 {
background-image: url(../images/btnUp.png);
cursor:pointer;
left:129px;
top:63px;
}
#btn1:active {
background-image: url(../images/btnDown.png);
}
.numKeypad {
bottom:2px;
font-size:20pt;
position:relative;
text-align:center;
font-family: 'Old Standard TT', serif;
}
.numKeypad:active {
bottom:0px;
font-size:18pt;
}

Found the best solution, had to change things up a bit.
new HTML
<div id="btn1" class="btnKeypad" onclick="input(1);">1</div>
new CSS
#btn1 {
background-image: url(../images/btnUp.png);
cursor:pointer;
left:129px;
top:63px;
}
#btn1:active {
background-image: url(../images/btnDown.png);
}
.btnKeypad {
font-family:'Old Standard TT', serif;
vertical-align:middle;
text-align:center;
position:absolute;
line-height:36px;
font-size:20pt;
z-index:100;
height:36px;
width:42px;
}
.btnKeypad:active {
line-height:37px;
font-size:18pt;
}
I still have an issue with the text aligning at the top of the button only in IE but the functionality now works on everything exactly the way I designed it to. I moved everything into one div and condensed it. Now to see about using a different CSS for internet explorer to get the text to align. Thanks to user3687283 for helping clean the code up a little.

Related

CSS : Want an input type number CSS just like google

I am trying to make the css of input type number just like in the Google Chrome.
but it is not working in my mozila browser.
I don't know how to make it just like it is seen in Google chrome.
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
cursor:pointer;
display:block;
width:8px;
color: #333;
text-align:center;
position:relative;
}
input[type=number]::-webkit-inner-spin-button:before,
input[type=number]::-webkit-inner-spin-button:after {
content: "^";
position:absolute;
right: 0;
font-family:monospace;
line-height:1px;
}
input[type=number]::-webkit-inner-spin-button:before {
top:0px;
}
input[type=number]::-webkit-inner-spin-button:after {
bottom:0px;
-webkit-transform: rotate(180deg);
}
<input type="number" value="10" max="15">
That's because you can't use pseudo classes on the ::webkit-inner-spin-button.
See this for a working example
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future. source

Styles for 'after' differ in browsers

I'm displaying a star after input box using :after. The styles are being rendered differently by different browsers. How can i make this appear similar in all the browsers. Please see this Fiddle in different browsers where in you can see the difference.
You can set width and height for a:after and give custom style to input (to avoid differences in padding, border, etc)
http://jsfiddle.net/omLc9nfe/7/
.a:after{
content:'*';
display:inline-block;
position:absolute;
top:-8px;
right:-8px;
width:8px;
height:8px;
text-align:center;
}
.a{
position: relative;
display:inline-block;
}
input {
border:1px solid #ccc;
margin:0;
padding:2px;
}
i've checked with safari, firefox and chrome.

CSS - placeholder text differs even if properties are same

I have search input beside navigation toggler. I want to style the text of placeholder as navigation toggler's heading but they are not similar even if the properties are same.
See:
::-webkit-input-placeholder {
color:#B2B4B5;
font-weight:bold;
font-size:15px;
}
:-moz-placeholder {
color:#B2B4B5;
font-weight:bold;
font-size:15px;
}
::-moz-placeholder {
color:#B2B4B5;
font-weight:bold;
font-size:15px;
}
:-ms-input-placeholder {
color:#B2B4B5;
font-weight:bold;
font-size:15px;
}
#menu-toggler > h4 {
width:auto;
padding:0 0 0 40px;
height:25px;
color:#B2B4B5;
}
Why ? Is it a bug? I am using Mozilla FF.
not sure what's going on but these might help you:
IE: http://msdn.microsoft.com/en-us/library/ie/hh772745(v=vs.85).aspx
Firefox: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-placeholder?redirectlocale=en-US&redirectslug=CSS%2F%3A-moz-placeholder
CSS Tricks: http://css-tricks.com/snippets/css/style-placeholder-text/
There maybe other proprety on your CSS file that overrides the one you set, like if the text is labeled as and you have set properties for that
I've noticed that FF requires you to be very specific with styling placeholders.
Instead of
:-moz-placeholder
try
input:-moz-placeholder
as class names (for example). Same counts for the ::-moz-placeholder styling.
Be as specific as possible, since FF tends to overwrite the placeholder if it has a more specific styling on the element.

ie-8 getting black outlines on images

i am developing a site and getting black outline in ie8
its looking great in all other major browser but not in ie-8
please help me this is my live link
http://www.cadellfoods.com.au/food-service-products.html
(the section in circular shape)
please help me
the code for all images is as following
#Section1
{
background:transparent url('Images/Chilled.png') no-repeat;
background-repeat:no-repeat;
border:none; outline:none; outline:0;
border-width: 0;
}
Seems OK in IE 8 too here. maybe you have issues in IE 8 on windows XP
as a good practice, you should not start your ID's or classes with capital letters.
Might not be it, but I have noticed IE puts borders on linked images. You need to undo those defaults.
#Section1 a:link img {
border:none;
}
Don't forget the :hover and :visited pseudos.
Just in case try these too
#Section1 img {
border:none;
}
#Section1 a:link {
border:none;
}

Why does Chrome use different fonts with the same CSS?

I have a span and an input element that share the same CSS definition for font. Why does Chrome use different fonts for them? How would I fix this issue?
My objective is to make them look exactly the same in IE9, Chrome and FF.
CSS definitions (FIXED), if they still matter.
* {
font-family: Verdana,Helvetica,Arial,sans-serif; /* Moving here fixed it */
}
body {
/*font-family: Verdana,Helvetica,Arial,sans-serif; -- This caused the issue*/
font-size: .8em;
margin: 0;
padding: 0;
color: #000;
}
.button
{
text-align:center;
min-width:80px;
display:inline-block;
white-space:nowrap;
background-color:#4A8CF6;
color:#FFF;
padding:4px;
margin:1px;
border:0;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
font-size: .8em;
}
Solution
The problem was that the span elements inherited from my CSS definition for body and the input elements didn't. I had defined the font in my CSS with body { font-family:...; } like my computed results show and I thought that using display: inline-block; would force both of them to inherit the font from body but it did not.
The solution was to switch to using * { font-family:...; } for the font definitions. The button and clickable classes simply defined sizes and colors and such.
You have to literally specify input elements if you want them to have the same font like so:
/* Or input[type=submit] depending on your needs */
span, input {
font-family: Arial, sans-serif; /* Your font here */
}
Otherwise the browser uses the default values as your question shows. You're looking under Computed Styles which shows that Chrome has decided the values for you as you haven't specified them.
You should apply CSS reset rules in the beginning of your style sheet. Its purpose is to make all elements have the same look in all browser.
Examples:
http://developer.yahoo.com/yui/reset/
http://meyerweb.com/eric/tools/css/reset/
Related question which can be useful too: https://stackoverflow.com/questions/116754/best-css-reset