How to simulate an active button in CSS for IOS Safari? - css

How can I style a button on IOS to look like the default active state?
I will be using touchstart, but want the button to look like a regular button that is being pressed.
HTML:
<button class="active"> I am pressed </button>
CSS:
button.active{
???
}
Images: (sorry, they are not the exact same crop-size)
EDIT: my latest attempt is:
button.active
{
border-radius: 12px;
border: 1px solid black;
background-color: #888;
box-shadow: 0 0 2px 2px #888;
}
It’s pretty close but the border shrinks in.

You could do this, faking a second border using the :before pseudo-elements
.active{
background:#e2e2e2;
font-weight:bold;
width:92px;
padding:.5em;
border:3px solid #e2e2e2;
border-radius:15px;
position:relative;
z-index:10;
}
.active:before{
content:"";
display:block;
position:absolute;
z-index:-1;
top:1px;
left:1px;
right:1px;
bottom:1px;
border:1px solid #000;
border-radius:15px;
}
Example: http://jsfiddle.net/E3jXr/

Related

Radio Button with rounded shadow on left in Chrome

How do I make the radio button shadow to be rounded in Chrome like how it is displayed in IE? Any help will be appreciated!
IE: (like this)
CHROME: (not like this)
HTML:
<div class="radio"><input type="radio"><label>C#</label></div>
<div class="radio"><input type="radio"><label>Java</label></div>
CSS
input[type="radio"] {
box-shadow: -4px 0 0 maroon;
border-radius: 10px;
}
JS FIDDLE:
http://jsfiddle.net/nikib/b85zpgu5/
You could change the -webkit-appearance property of the input element to get initial or inherit. Then style is according to your need.
input[type="radio"] {
width:15px;
height:15px;
box-shadow: -4px 0 0 maroon;
border-radius: 999px;
-webkit-appearance: inherit;
border:1px solid #999999;
position:relative;
box-sizing:border-box;
}
input[type="radio"]:checked:before {
content:"";
position:absolute;
border-radius: 999px;
left:25%;
top:25%;
width:50%;
height:50%;
background:#999999;
}
Updated Fiddle

How to reduce space between buttons?

I am new to css and html5 and trying to get top buttons to work properly. The buttons are horizontal align left. I can seem to be adding the proper space between them. How can fix my code without messing my page lay out? Thank you very much for your help here is the code:
.dashboard, #logOuta {
width:160px;
padding:10px 25px 12px 26px;
font-size:18px;
text-decoration:none;
font-family:Arial;
color:#fff;
text-align:center;
box-shadow:1px 1px 1px #666;
background:#23A3DA;
background-image:-webkit-linear-gradient(top,#23A3DA,#03171F);
background-image:-moz-linear-gradient(top,#23A3DA,#03171F);
background-image:-ms-linear-gradient(top,#23A3DA,#03171F);
background-image:-o-linear-gradient(top,#23A3DA,#03171F);
background-image:linear-gradient(to bottom,#23A3DA,#03171F);
border-bottom:2px solid #ffd175;
-webkit-border-radius:5;
-moz-border-radius:5;
border-radius:5px;
-webkit-box-shadow:1px 1px 1px #666;
-moz-box-shadow:1px 1px 1px #666;
cursor:pointer
}
.dashboard:hover {
background:#E3A019;
background-image:-webkit-linear-gradient(top,#E3A019,#E3A019);
background-image:-moz-linear-gradient(top,#E3A019,#E3A019);
background-image:-ms-linear-gradient(top,#E3A019,#E3A019);
background-image:-o-linear-gradient(top,#E3A019,#E3A019);
background-image:linear-gradient(to bottom,#E3A019,#E3A019);
text-decoration:none
}
<div class="logoutbox">
<button class="dashboard">Dashboard</button>
<input name="logOuta" type="button" id="logOuta" value="Sign Out"/>
</div>
button {
margin-right: 50px; /* whaever spacing you want */
}

IE Showing black border outline on submit button

I am trying to understand why IE 7>10 is showing a black border on a submit button. In order to clear it, I have to click inside the fieldset and then it goes away. But comes back when I click send or cancel. Is this a common problem with IE? I have included screenshot. Thanks!
css code
.submit
{
margin:-50px 0 0 -148px;
background-color:#eee;
height:40px;
width:120px;
padding:0;
border:1px solid #666;
color:#42A0FF;
}
.cancel
{
margin: -51px 0 0 -20px;
background-color:#eee;
height:40px;
width:120px;
padding:0;
border:1px solid #666;
color:#42A0FF;
}
fieldset
{
background:#f2f2e6;
border-color:#cccccc #cccccc #cccccc #cccccc;
margin:10px 0 46px -150px;
width:404px;
display:block;
text-height:10px;
padding-bottom:15px;
}
Try resetting the main input
input {border:0; margin:0;padding:0;}
And add a span to give the span the border you want so it will work universally:
.input-shell {border: #ccc 1px solid}
<span class="input-shell"><input button /></span>....
Heres a JSFIDDLE:
http://jsfiddle.net/Riskbreaker/tqnhg/1/
Heres a ref of same thing:
Any way to remove IEs black border around submit button in active forms?
Finally do this:
input[type=submit],
input[type=reset],
input[type=button]
{
filter:chroma(color=#000000);
color:#cccccc;
}

CSS issue - aligning a span to another

I'm making an error message, using a pointer image that should give the left side a border. You can see an example here.
My current css is:
span.arrow {
background-color:white;
background: url('http://i45.tinypic.com/201d0n.png') no-repeat left center;
height:17px;
display:inline-block;
}
span.error {
display:inline-block;
padding-right:2px;
background-color:white;
margin-left:10px;
height:15px;
font-size:small;
border-top:1px solid #99182c;
border-right:1px solid #99182c;
border-bottom:1px solid #99182c;
box-shadow:5px 5px 10px #888888;
position:relative;
top:-2px;
}
And html to display the error:
<span class='arrow'>
<span class='error'>
Errormessage.
</span>
</span>
Now first of all, the code seems a bit messy. Like having to position the span up two pixels is a bit strange. Nevertheless it seems to work in Chrome, FF & Opera, but not in IE9.
If it isn't clear: the box should perfectly aline with the triangle-image.
span.arrow {
background: url('http://i45.tinypic.com/201d0n.png') no-repeat left center transparent;
line-height:17px;
padding-left:10px;
display:inline-block;
}
span.error {
padding-right:2px;
background-color:white;
line-height:15px;
font-size:small;
border-top:1px solid #99182c;
border-right:1px solid #99182c;
border-bottom:1px solid #99182c;
display:block;
}
span.error {
display:inline-block;
padding-right:2px;
background-color:white;
margin-left:10px;
line-height: 17px;
font-size:small;
border-top:1px solid #99182c;
border-right:1px solid #99182c;
border-bottom:1px solid #99182c;
box-shadow:5px 5px 10px #888888;
position:relative;
top:-2px;
}
Generally if you make your line-height match your content area height, the text will be vertically aligned.
http://jsfiddle.net/dshFk/3/
I looked in IE and it looked fine.

Menu triangle/arrow issue (pure CSS)

I have a triangle next to menu items, using pure CSS. It works flawlessly in Internet Explorer and Firefox but Chrome crops the bottom of the arrow. Here's some screenshots of the issue:
Here is the CSS I'm using:
/*menu arrows */
.arrowsprite {
width:0px;
height:0px;
border-left:5px solid transparent;
border-right:5px solid transparent;
border-top:5px solid #444444;
font-size:0px;
line-height:0px;
top:-2px;
position:relative;
}
.arrowspriteselected {
width:0px;
height:0px;
border-left:5px solid transparent;
border-right:5px solid transparent;
border-top:5px solid #fff;
font-size:0px;
line-height:0px;
top:-2px;
position:relative;
}
.leftish li:hover .arrowsprite {
border-top:5px solid #444444;
}
.leftish li:hover .arrowspriteselected {
border-top:5px solid #444444;
}
The HTML is:
<li>Wanted <span class="arrowsprite"></span></li>
Does anyone see any glaring problems in my CSS?
Try setting display to inline-block for your .arrowsprite rule. See this fiddle for an example.
.arrowsprite {
width:0px;
height:0px;
border-left:5px solid transparent;
border-right:5px solid transparent;
border-top:5px solid #444444;
font-size:0px;
line-height:0px;
top:-2px;
position:relative;
display:inline-block;
}
It's working for me in Chrome 14.0.803.0 dev.
I'm not able to reproduce what you see in Chrome 12.0.742.112. For me, the span didn't even show up with that CSS and HTML. However, I tried putting in a non-breaking space, and then I was able to see it and it displayed fine.
<li>Wanted <span class="arrowsprite"> </span></li>
Here's a fiddle to compare with and without the non-breaking space. Notice that on Firefox at least the method gives more space (no pun intended), so see if you can still make it do what you want. If you can't, the next thing to try would be a float for your list elements (See this question for why).

Resources