CSS outline width not working - html

I am trying to set outline width of the input element on focus.
Outline width stays the same (like it is default setting which can not be changed), no matter of my setting.
Here is example from code pen
And here is part from css where I am trying to set outline-width on focus:
input:focus {
outline-width: 0.1px;
outline-color: #725b44;
}
EDIT:
I've just forgotten to include line style (solid, dotted...).
Now it works. One thing is still strange to me. Why is outline inside element?
Isnt' the outline defined as 'a line that is drawn around elements (outside the borders) to make the element "stand out".'
Here from my example outline looks like this. I thought it's going to be around element, but it's inside:

Add outline-style: solid to your css.
Since the default style for the outline-style property is none, you will have to set it as well (none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|initial|inherit). Best value you can use for the style is solid, but that's a matter of preference.
Example for the behavior:
input {
font-size: 22px;
padding: 5px 3px;
color: #666;
}
input.with-outline-style:focus {
outline-width: 3px;
outline-style: solid;
outline-color: #725b44;
/* You could also use the shorthand: */
/* outline: 3px solid #666; */
/* width style color */
}
input.without-outline-style:focus {
outline-width: 3px;
outline-color: #725b44;
}
body {
background-color: #fd9;
}
div {
padding: 5px 10px;
}
<div>
<input type="text" class="with-outline-style" value="outline-style set to solid" />
</div>
<div>
<input type="text" class="without-outline-style" value="outline-style not set" />
</div>
Update
The outline-width setting doesn't work without specifying outline-style: if no outline style is set, the browser will render the outline in its default style (which could be anything, such as a dotted rectangle in IE, a shaded rectangle in Chrome, or even nothing).

Use outline-style
input:focus {
outline-width: 0.1px;
outline-color: #725b44;
outline-style: dotted;
}

Only if you specify outline-style the outline-width will take effect. Please check and let me know your feedback. Thanks!
snippet below:
.divMain {
height: 100vh;
width: 100vw;
border: 0px solid black;
}
.divLogin {
position: absolute;
left: 20%;
top: 5%;
width: 300px;
height: 600px;
border: 1px solid #CF6B08;
border-radius: 3px;
}
#divLogin {
background: #FFCC99;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(#FAC28A, #FFCC99);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#FAC28A, #FFCC99);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#FAC28A, #FFCC99);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#FAC28A, #FFCC99);
/* Standard syntax */
}
.spanTitle {
position: absolute;
top: 10px;
left: 10px;
font-size: 20px;
color: #003399;
font-weight: bold;
}
.inputFirst {
position: absolute;
top: 50px;
margin-left: 5px;
width: calc(100% - 10px);
height: 30px;
}
.divWarningInputFirst {
position: absolute;
width: calc(100% - 10px);
height: 30px;
top: 88px;
margin-left: 5px;
border: 0px solid black;
background-color: #fcdcbb;
color: #ff0000;
font-weight: bold;
padding-top: 5px;
padding-left: 5px;
}
.divWarningInputFirst:after {
content: "";
position: absolute;
top: -5px;
left: 8px;
border-style: solid;
border-width: 0 5px 6px;
border-color: #fcdcbb transparent;
display: block;
width: 0;
z-index: 1;
}
input:focus {
outline-width: 3px;
outline-style: solid;
outline-color: #725b44;
}
input {
border-color: transparent;
padding-left: 3px;
box-sizing: border-box;
}
<div id="divMain" class="divMain">
<div id="divLogin" class="divLogin">
<span id="spanTitle" class="spanTitle">Login</span>
<input type="text" id="inputFirst" class="inputFirst" placeholder="input first">
<div id="divWarningInputFirst" class="divWarningInputFirst">Please enter input first</div>
</div>
</div>

Try
outline: 3px solid #725b44;
or
outline-width:3px;
outline-color:#725b44;
outline-style:solid;
.divMain {
height: 100vh;
width: 100vw;
border: 0px solid black;
}
.divLogin {
position: absolute;
left: 20%;
top: 5%;
width: 300px;
height: 600px;
border: 1px solid #CF6B08;
border-radius: 3px;
}
#divLogin {
background: #FFCC99;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(#FAC28A, #FFCC99);
/* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#FAC28A, #FFCC99);
/* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#FAC28A, #FFCC99);
/* For Firefox 3.6 to 15 */
background: linear-gradient(#FAC28A, #FFCC99);
/* Standard syntax */
}
.spanTitle {
position: absolute;
top: 10px;
left: 10px;
font-size: 20px;
color: #003399;
font-weight: bold;
}
.inputFirst {
position: absolute;
top: 50px;
margin-left: 5px;
width: calc(100% - 10px);
height: 30px;
}
.divWarningInputFirst {
position: absolute;
width: calc(100% - 10px);
height: 30px;
top: 88px;
margin-left: 5px;
border: 0px solid black;
background-color: #fcdcbb;
color: #ff0000;
font-weight: bold;
padding-top: 5px;
padding-left: 5px;
}
.divWarningInputFirst:after {
content: "";
position: absolute;
top: -5px;
left: 8px;
border-style: solid;
border-width: 0 5px 6px;
border-color: #fcdcbb transparent;
display: block;
width: 0;
z-index: 1;
}
input:focus {
outline: 3px solid #725b44;
}
input {
border-color: transparent;
padding-left: 3px;
box-sizing: border-box;
}
<div id="divMain" class="divMain">
<div id="divLogin" class="divLogin">
<span id="spanTitle" class="spanTitle">Login</span>
<input type="text" id="inputFirst" class="inputFirst" placeholder="input first">
<div id="divWarningInputFirst" class="divWarningInputFirst">Please enter input first</div>
</div>
</div>
This might help you!

You should add 1px instead of 0.1px with outline-style
input:focus {
outline:1px solid #725b44;
}

Related

Border behind Button slight below position CSS

I m trying to implement below button CSS, I tried to used box-shadow as well psuedo code i.e before after still not getting the output I wanted.
the button that I wanted:
my code:
.et_pb_button {
background-color: #f16922!important;
width: 65%;
outline: 3px solid #f16922;
outline-offset: 10px;
text-transform: uppercase;
font-size: 14px!important;
}
Button
Please see below snippet:
button {
position: relative;
display: inline-block;
vertical-align: top;
background-color: blue;
color: #fff;
border-radius: none;
text-transform: uppercase;
border: none;
padding: 10px 12px;
}
button::after {
content: '';
position: absolute;
top: 5px;
left: -5px;
right: -5px;
bottom: -5px;
border: 1px solid red;
display: block;
z-index: -1;
}
<button>View Project</button>
.btngroup button{
background-color: rgb(29, 174, 236);
border: 0;
padding: 10px 15px;
font-size: 15px;
color: white;
width: 150px;
height: 50px;
text-transform: uppercase
}
.btngroup .drop{
width: 165px;
height: 50px;
border: 1.5px solid red;
margin-top: -42.5px;
}
<center>
<div class="btngroup">
<button>view project</button>
<div class="drop"></div>
</div>
</center>
Here is an idea with one element and multiple background and border-image:
.button {
display:inline-block;
padding:10px 60px 20px;
margin:10px;
color:#fff;
border:2px solid transparent;
border-image:linear-gradient(to bottom,transparent 10px,red 0) 2;
background:
linear-gradient(blue,blue) top center/calc(100% - 20px) calc(100% - 10px),
linear-gradient(red,red) 0 8px /100% 2px;
background-repeat:no-repeat;
}
<span class="button">Button</span>
And with CSS variable to easily control the whole shape:
.button {
--t:10px; /* Distance of the border from the top*/
--p:10px; /* Distance between the border and background*/
--b:2; /* Thickness of the border (unitless to be used with slice)*/
--c:red; /* border color*/
display:inline-block;
padding:var(--p) 60px calc(2*var(--p));
margin:10px;
color:#fff;
border:calc(1px*var(--b)) solid transparent;
border-image:linear-gradient(to bottom,transparent var(--t),var(--c) 0) var(--b);
background:
linear-gradient(blue,blue) top center/calc(100% - 2*var(--p)) calc(100% - var(--p)),
linear-gradient(var(--c),var(--c)) 0 calc(var(--t) - 1px*var(--b))/100% calc(1px*var(--b));
background-repeat:no-repeat;
}
<span class="button">Button</span>
<span class="button" style="--c:green;--t:15px;--p:8px;--b:3;">Button</span>
<span class="button" style="--c:#000;--t:25px;--p:15px;--b:1;">Button</span>
Here's an alternative based on Hanif's suggestion, which uses both pseudo-elements instead of one with a negative z-index. For some backgrounds (e.g. an image or gradient), it might be necessary to adjust the background-position for the ::after
button {
position: relative;
display: inline-block;
vertical-align: top;
background-color: blue;
color: #fff;
border-radius: none;
text-transform: uppercase;
border: none;
padding: 10px 12px;
}
button::before {
content: '';
position: absolute;
top: 5px;
left: -5px;
right: -5px;
bottom: -5px;
border: 1px solid red;
display: block;
}
button::after {
content: '';
position: absolute;
top: 5px;
left: 0;
right: 0;
height: 1px;
background: inherit;
display: block;
}
<button>View Project</button>

Border style is not working in Internet explorer 11

I have created a toggle-button that is not working in the IE-browser. I have doubts regarding the web-kit appearance and the border.
Here is a working snippet of my code:
.contain {
position: relative;
display: inline-block;
width: 48px;
height: 24px;
background: #d6d6d6;
border-radius: 20px;
margin: 10px;
}
.checkbox {
position: absolute;
width: 28px;
height: 28px;
-webkit-appearance: none;
background: white;
border: 1px solid;
border-radius: 50%;
top: -5px;
left: -10px;
outline: none;
}
.checkbox:checked {
left: 20px;
}
<label class="contain" >
<input type="checkbox" id="checkbox" class="checkbox" />
</label>
The border is fine in Chrome but in the Internet-Explorer the border-radius is not applied.
It appears that the problem is with the .checkbox element, you haven't specified a border color for it which might be why you aren't seeing the border.
You could add it at the end of the border property, like this:
.checkbox {
width: 28px;
height: 28px;
position: absolute;
top: -5px;
left: -10px;
-webkit-appearance: none;
border: 1px solid red;
border-radius: 50%;
outline: none;
background: white
}
Or you could split the border property into border-width, border-style and border-color properties, like this:
.checkbox {
width: 28px;
height: 28px;
position: absolute;
top: -5px;
left: -10px;
-webkit-appearance: none;
border-width: 1px;
border-style: solid;
border-color: red;
border-radius: 50%;
outline: none;
background: white
}
Another thing you could try to do is make the border thicker, by changing the border's width (1px) to 2px/3px.
Good luck.
just add
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
to the checkbox class

Different result for different browser with CSS

I have different results for different browsers in the following code:
.flexsearch--wrapper {
height: auto;
width: 50%;
max-width: 700px;
min-width: 100px;
top: 20px;
overflow: hidden;
background: transparent;
margin: 1px;
position: absolute;
}
.flexsearch--form {
overflow: hidden;
position: relative;
}
.flexsearch--form {
padding: 0 66px 0 0;
/* Right padding for submit button width */
overflow: hidden;
}
.flexsearch--input {
width: 100%;
}
.flexsearch {
padding: 0 25px 0 200px;
/* Padding for other horizontal elements */
}
.flexsearch--input {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 30px;
padding: 0 46px 0 10px;
border-color: #888;
border-radius: 3px;
/* (height/2) + border-width */
border-style: solid;
border-width: 2px;
/*margin-top: 10px;*/
color: #333;
font-family: 'Helvetica', sans-serif;
font-size: 16px;
-webkit-appearance: none;
-moz-appearance: none;
}
.flexsearch--submit {
position: absolute;
right: 0;
top: 0;
display: block;
width: 32px;
height: 32px;
padding: 0;
border: none;
margin-top: 4px;
/* margin-top + border-width */
margin-right: 5px;
/* border-width */
background: transparent;
color: #888;
font-family: 'Helvetica', sans-serif;
font-size: 30px;
line-height: 30px;
-webkit-appearance: none;
-moz-appearance: none;
}
.flexsearch--input:focus {
outline: none;
border-color: #333;
}
.flexsearch--input:focus.flexsearch--submit {
color: #333;
}
.flexsearch--submit:hover {
color: #333;
cursor: pointer;
}
/* UPLOAD ICON IMAGE */
#uploadIcon {
/*width: 10%;
height: 100%;*/
padding-top: 10px;
min-width: 80px;
max-width: 80px;
position: absolute;
margin: 0 1% 0 77%;
/* left : 77%;*/
top: -3px;
}
/* SIGN UP / SIGN IN*/
.Signin {
position: fixed;
/*left: 85%;*/
margin-left: 86%;
top: 24px;
/*border : 1.5px solid grey;*/
padding: 3px;
margin-right: 2px;
float: right;
}
/*#Signup {
position: absolute;
left: 93%;
top: 20px;
border : 1.5px solid grey;
padding: 3px;
margin-right: 3px;
}
*/
<div class="flexsearch">
<div class="flexsearch--wrapper">
<form class="flexsearch--form" action="#" method="post">
<div class="flexsearch--input-wrapper">
<input class="flexsearch--input" type="search" placeholder="search">
</div>
<input class="flexsearch--submit" type="submit" value="➜" />
</form>
</div>
</div>
<img src="upload_icon.png" id = "uploadIcon">
Sign In/Sign Up
<!-- Sign Up -->
The problem is that arrow and the Sign In and Sign Up with Firefox works perfectly :
But with Chrome or Safari it doesn't:
Is the problem from my code? or do I need to add some customized code for each browser. And if yes, how can that be done? Can it be done with -webkit or -moz Because I tried this, but it didn't work. Probably, I haven't written it well.

Fixing opacity of content inside div

I have a div that has a background image but has 50% opacity.
Now I have a div that is child and I want what every the content it has to have 100% opacity. You can see in the snipplet headings and textbox and button has less opacity.
Can anyone help how to fix this thing? I tried to apply opacity 100% to child but it didn't work.
/* CSS to be fixed*/
#home_div
{
background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Shoppers_on_Dundas%2C_near_Yonge.jpg/1200px-Shoppers_on_Dundas%2C_near_Yonge.jpg");
opacity: 0.5;
filter: alpha(opacity=50);
/*background-color: #0050A0;*/
background-color: lightgrey;
padding-top: 200px;
color: white;
padding-bottom: 200px;
height: 100%;
}
#home_div_content
{
opacity: 1.0;
filter: alpha(opacity=100);
text-align: center;
}
#header
{
height: 70px;
border-bottom: 4px solid lightgrey;
}
#header_content
{
margin-top: 10px;
margin-left: 80px;
}
.brandmark
{
margin-top: -20px;
}
.link_to a
{
color: #0050A0 !important;
}
.featured_div
{
display: none;
}
.featured_close_anchor, .featured_anchor_close
{
text-align: center;
}
#heading, #tag_line
{
top: -300px;
position:relative;
color: #0050A0;
}
#search
{
border-radius: 0 !important;
border-color: #0050A0 !important;
width: 60%;
height: 35px;
padding: 8px 15px;
color: #0050A0; /* change color of text to be typed inside search box */
font-size: 13px;
line-height: 20px;
background-color: transparent;
border: 1px solid #ccc;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn-custom {
color: #FFFFFF;
background-color: #0050A0; /* change button color */
border-radius: 0!important; /* button border radius */
padding: 5px 11px; /* Button size change*/
margin-top: -3.5px;
border-top: 2px solid #0050A0;
border-bottom: 3px solid #0050A0;
margin-left: -3px;
}
.btn-custom:hover{
background-color:#9AC94B; /* change button color on hover */
border-radius: 0!important;
}
.left_categories
{
padding-top: 5px;
padding-bottom: 5px;
margin-bottom: 1px;
border-left: 4px solid #0050A0;
}
.left_categories:hover
{
border-top: 1px solid lightgrey;
border-bottom: 1px solid lightgrey;
border-left: 4px solid #E5002B;
}
.active_category
{
background-color: #0050A0;
color: white !important;
border-left: 4px solid #E5002B;
}
.search_section
{
margin-top: 30px;
}
a
{
text-decoration: none !important;
}
.flash_nav
{
height: 90px;
border: 0 !important;
background-color: #283442;
}
.gradient
{
background: -moz-linear-gradient(left, white 0%, white 45%, #12A8E0 85%, #0050A0 100%);
}
.flash_navbar a
{
color: black !important;
}
.search_form
{
width: 70%;
}
.nav_form
{
border-radius: 0;
margin-top: 27px;
}
#searchBar
{
border-color: #0050A0;
}
#searchButton
{
background-color: #0050A0;
color: white;
border: none;
}
<div id="home_div">
<div class="container" id="home_div_content">
<h1 id="heading">Find your product!</h1>
<h4 id="tag_line">Search what you are looking for.</h4>
<form method="GET" action="/product/search">
<input type="text" name="product" id="search" placeholder="Enter product name" class="searchTextBox" />
<button type="submit" id="quick-search" class="btn btn-custom"><span class="glyphicon glyphicon-search custom-glyph-color"></span></button>
</form>
<br />
view <i class="fa fa-chevron-down"></i> featuring
</div>
</div>
FIDDLE
An opacity rule will always affect child/descendant elements since they are part of the parent, and the rule says the parent should be 50% opacity.
To get round this, use a pseudo element and give that reduced opacity rather than the parent.
HTML
<div id='outer'>
<div id='inner'></div>
</div>
CSS
#outer { width: 200px; height: 200px; position: relative; padding: 2em; }
#outer::before { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: red; opacity: .5; z-index: -1; }
#inner { width: 100%; height: 100%; background: blue; }
Fiddle.

create tag shape with css

I'm trying to create a tag shape with the css only so that it looks like:
I'm trying following but unable to use the border for the triangle area.
HTML:
Test
CSS:
a{
float: left;
height: 35px;
position:relative;
border: 1px solid red;
border-right: none;
width: 100px;
}
a:before{
content: "";
position: absolute;
top: -1px;
right: -18px;
width: 0;
height: 0;
border-color: white white white red;
border-style: solid;
border-width: 19px 0 18px 18px;
}
JSFiddle:
http://jsfiddle.net/Sac3m/
You could rotate a square instead, although i doubt the results will be great cross-browser
Modified code:
a {
float: left;
height: 35px;
position: relative;
border: 1px solid red;
border-right: none;
width: 100px;
}
a:after {
content: "";
position: absolute;
top: 4px;
right: -13px;
width: 25px;
height: 25px;
border: 1px solid red;
border-left: none;
border-bottom: none;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}
<a></a>
(Latest IE, Firefox and Chrome seems OK with it)
Update
If you need IE8 support, you could try to put a white triangle on top of the (original) red triangle:
a {
float: left;
height: 36px;
position: relative;
border: 1px solid red;
border-right: none;
width: 100px;
}
a:before {
content: "";
position: absolute;
top: -1px;
right: -18px;
width: 0;
height: 0;
border-color: white white white red;
border-style: solid;
border-width: 19px 0 19px 19px;
}
a:after {
content: "";
position: absolute;
top: 0;
right: -17px;
width: 0;
height: 0;
border-color: transparent transparent transparent white;
border-style: solid;
border-width: 18px 0 18px 18px;
}
<a></a>
The below code helps to create a tag shape. It works in all major browsers.
#swc {
position: relative;
margin: 0 5px 0 10px;
display: inline-block;
height: 66px;
padding: 0 35px 0 20px;
font-size: 25px;
line-height: 65px;
cursor: pointer;
font-weight: 100;
margin: 20px 25px;
background: #f3f3f3;
transition: background 0.3s;
}
#swc:after {
position: absolute;
content: "";
right: -19px;
width: 1px;
height: 0px;
border-left: 18px solid #f3f3f3;
border-top: 33px solid transparent;
border-bottom: 33px solid transparent;
transition: border 0.3s;
}
#swc:hover {
background: green;
color: #ffffff;
}
#swc:hover:after {
border-left-color: green;
}
<span class="pricetag-right" id="swc">Tag Content!</span>
We had a slightly different implementation of this that produces rounded corners. This uses a rounded square that's turned 45°.
.tag {
display: inline-block;
border-width: 1px;
border-style: solid;
border-color: #c8d7f2 transparent #c8d7f2 #c8d7f2;
border-radius: .25em 0 0 .25em;
padding: 0.1em 0.6em 0.1em 0.3em;
background-color: #e5ecf9;
line-height: 1.2em;
}
.tag:after {
content: "\25CF";
position: absolute;
display: inline-block;
height: 1.2em;
width: 1.17em;
transform: rotate(45deg);
color: white;
text-indent: 0.3em;
line-height: 1em;
text-shadow: 0 0 1px #333;
background-color: #e5ecf9;
border-radius: 0.33em 0.33em 0.33em 1em;
border-width: 1px;
border-style: solid;
border-color: #c8d7f2 #c8d7f2 transparent transparent;
}
<h1 class="tag">my-tag</h1>
A couple things to note:
The square contains a circle punctuation mark. To adjust it you use line-height and text-indent.
The borders on the square need to be set to transparent color with a width of 1px. If you don't, the other borders (the visible ones) taper off where they go from 1px to 0px.
his works pretty well and it's nearly pixel-perfect, but it does render slightly differently across Chrome and Firefox. I tried to make it work with a transparent background, but you need some sort of color to cover up the funkiness where the square meets the tag. It's not quite perfect.
The nice thing about this is that it can be applied as a class and it can be used on H1-H6, or p tags.