CSS outline best practices [closed] - css

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
There has been some controversy regarding the practice of doing the following:
a, input, textarea, button {
outline: none;
}
Accessibility issues are a common concern.
It is not my intention to remove this feature altogether (as the code above does); however, this feature greatly messes with my original design by adding unintended borders (erm, outlines?) in unwelcome areas.
The main problem is that these outlines actually follow the rectangular area around the element, not its contour (i.e. it ignores border radius, etc.).
Example:
div {
margin: 64px;
}
input {
font-size: 20px;
border-radius: 16px;
border: 2px solid #CCC;
padding: 2px 12px;
}
button {
font-size: 20px;
border-radius: 32px;
text-transform: uppercase;
color: #FFF;
border: 2px solid #CCC;
background: #CCC;
padding: 6px 3px;
cursor: pointer;
}
<div>
<input type="text" placemark="Search query..."/>
<button>Go</button>
</div>
The only solution of which I am aware is to have the above code running and employ my own system.
What are the best practices when taking this approach?

Indeed. An outline is around the rectangular area on the outside of the border. It doesn't take rounded corners into account.
There's nothing wrong with disabling the outline, just make sure you add some other accessibility feature for people using the keyboard, for instance, change the color of your background on focus:
div {
margin: 64px;
}
input {
font-size: 20px;
border-radius: 16px;
border: 2px solid #CCC;
padding: 2px 12px;
outline: 0;
}
button {
font-size: 20px;
border-radius: 32px;
text-transform: uppercase;
color: #FFF;
border: 2px solid #CCC;
background: #CCC;
padding: 6px 3px;
cursor: pointer;
}
input:focus {
border-color: #999;
}
<div>
<input type="text" placemark="Search query..."/>
<button>Go</button>
</div>

As many form elements, the button element has different renderings in browsers, and as many fixes are needed...
http://fvsch.com/code/button-css/ from F. Verschelde should let you outline buttons around the whole element and not around its content.

Related

Stop button where the text stops [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a little CSS issue right here. I'm creating a simple button and I have the desired effect and all; but the button doesn't stop and acts like width:100% while I have width set to auto. I have put my code below and the effect is currently has.
>> CURRENT OUTCOME
a.abutton {
display:block;
background-color: #49b4df;
background-image: -webkit-linear-gradient(#49b4df, #2497c5);
background-image: -moz-linear-gradient(#49b4df, #2497c5);
background-image: -o-linear-gradient(#49b4df, #2497c5);
background-image: linear-gradient(#49b4df, #2497c5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#49B4DF', EndColorStr='#2497C5');
width: auto;
height: 31px;
color: #fff;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
margin: 0px 0px 0px 0px;
padding: 2px 5px 5px 5px;
border: 0px none;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-moz-box-shadow: 1px 1px 2px #919191;
-webkit-box-shadow: 1px 1px 2px #919191;
box-shadow: 1px 1px 2px #919191;
}
Question: How do I stop the button from expanding and stop where the text also stops?
Try to change
display: block;
by
display: inline-block;
"width:auto" inherit the parent "width" with a "display: block."
You need to change the display to inline-block

Why the input box is showing so different on iPad but not on chrome [duplicate]

This question already has answers here:
iOS forces rounded corners and glare on inputs
(6 answers)
Closed last month.
I have a site which is working properly except for the input field and submit button next to it. They are not showing properly on iPad. The height of the input box is slightly more than the submit button, making it look weird.
What I think is that Safari mobile has different viewports(1024px) etc, but renders the same WebKit appearance as of Chrome. Then why the input box is showing different on iPad?
Here is how it looks in Google Chrome on my desktop:
And here is how it looks on iPad:
The HTML part goes simply as:
<div id="search-form">
<input id="Search" class="defaultText defaultTextActive" title="search shzamm!" type="text" spellcheck="false">
<input onclick="javascript:someFunction();" type="button" value="Go" class="search_btn">
</div>
And the CSS for the same is:
#search-form {
overflow: auto;
box-shadow: -1px 1px 3px rgba(0, 0, 0, 0.1);
margin-bottom: 26px;
}
input#Search {
-webkit-appearance: none;
border-radius: 0;
-webkit-border-radius: 0;
}
.defaultText {
width: 88%;
padding-left: 4px;
height: 29px;
float: left;
background-color: #f7f7f7;
border-right: 0px solid #666;
border-bottom: 1px solid #666;
border-color: #999;
margin-right: -33px;
}
.defaultTextActive {
color: #999;
font-style: italic;
font-size: 15px;
font-weight: normal;
}
.search_btn {
font-size: 13px;
font-weight: bold;
height: 34px;
cursor: pointer;
float: right;
margin: 0;
width: 33px;
background: url("../images/search.jpg") no-repeat;
text-indent: -99999px;
border: 1px solid #999;
border-top: 2px solid #000;
margin-top: 0px;
margin-right: 1px;
}
As you can see, the border effects of input are also not being rendered properly in iPad. Anyone have any clue about it?
This snippet of CSS will remove the default WebKit styling from your textboxes:
input[type="text"] {
-webkit-appearance : none;
border-radius : 0;
}
Works on iOS 7 too.
Try to use -webkit-appearance to get rid of the default styles.
Check this answer: iOS forces rounded corners and glare on inputs

Adding style to active link? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Hi at my site website (password: ebriff) i have added small white triangles as pictures to the active link. But since i have a picture as my first menu link, it won't get added to that. How do I get around this?
CSS:
.top-menu li{
margin: 0;
float: left;
font-family: 'Oswald', sans-serif;
text-transform: uppercase;
color: #fff; /* text color */
font-size: 15px;
text-shadow: 0 1px 0 rgba(0,0,1,.5); /* drop shadow */
letter-spacing: 1px;
font-weight: 300;
}
li.top {
border-right: 1px solid #007472;
border-left: 1px solid #009C9A;
}
li.top:last-child {
border-right: none;
}
li.top:first-child {
width: 70px;
border-left: none;
background: url({{'home-icon.png'|asset_url}}) no-repeat 24px 25px;
text-indent: -9999px;
}
.current {
background: url({{'triangle.png'|asset_url}}) no-repeat center bottom}
}
You can put the home icon as background image for the link instead of the list item. At least this worked for me when I tried it in chrome developer tools ;)
So instead of
li.top:first-child {
width: 70px;
border-left: none;
background: url({{'home-icon.png'|asset_url}}) no-repeat 24px 25px;
text-indent: -9999px;
}
use
li.top:first-child {
width: 70px;
border-left: none;
text-indent: -9999px;
}
li.top:first-child a{
background: url({{'home-icon.png'|asset_url}}) no-repeat 24px 25px;
}
You may use CSS3 multiple backgrounds
background: url(...), url(...);
or you may manually create an image with arrow overlayed over the "normal background icon" and use it for the :active selector.
Consider using CSS sprites as well.
On multiple backgrounds: http://www.css3.info/preview/multiple-backgrounds/

CSS Webpage elements are not positioning correctly [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to code a design into HTML and CSS. It is a small snippet. I am having issues with the positioning and cant seem to put elements in their correct places.
My webpage can be found at http://www.sarahjanetrading.com/js/j/index.html
The design that I want to copy can be found here: http://www.sarahjanetrading.com/js/j/people-list.png
I also want the checkbox input to look like the one in the design. Can checkboxes be styled?
Change Your CSS like this :
#people-list #content h2 {
font-size: 16px;
float: left;
margin-left: 10px;
margin-top: 5px;
width: 355px;
}
#people-list #content small {
font-size: 12px;
color: #8F9092;
margin: 5px 0 8px;
display: block;
float: left;
width: 355px;
display: block;
margin-left: 9px;
}
#people-list #content .tags {
border-radius: 7px;
box-shadow: inset 0px 6px 2px 8px #f5f5f5;
border: 1px solid #E3E3E3;
padding: 2px;
font-size: 9px;
margin-right: 3px;
margin-left: 10px;
}
and Check this link for styling checkbox
http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
yes ,checkbox can be styled, try to put the buttons in a div and change the display attribute to inline

Can't seem to get submit/buttons/anchors to line up

Some times I may may want an anchor beside a submit button, but I always seem to have problems lining them up ...
a, input[type=submit], input[type=button], button {
font-family: arial;
background: #fff;
color: #777;
border: 1px solid #ccc;
font-size: 12px;
line-height: 20px !important;
padding: 5px 10px;
margin: 0;
}
http://jsfiddle.net/cXgzM/
with that, anchors are still 2 pixels short
Simply add this to your CSS:
a
{
display: inline-block;
}
I updated your example. Note that this property doesn't work in IE7 and lower. :)

Resources