I've styled a checkbox and wanted to make a checkmark with the :after element. However, I can not turn it around. The same style attached to a div works fine.
Used style:
content: '';
position: absolute;
width:.5em;
height:.2em;
transition: all .2s;
border-left: 2px solid red;
border-bottom: 2px solid red;
top: 0.4em;
left: 0.3em;
transform: rotate(-45deg);
See a Codepen here: Codepen
Multiple transform overrides the previous transform. Better to write them as shorthand
transform: rotate(-45deg) scale(1);
Try this code
.wb_checkbox {
position: relative;
}
.wb_checkbox>input[type="checkbox"] {
cursor: pointer;
position: absolute;
left: 3px;
top: 0;
z-index: 2;
width: 26px;
height: 26px;
opacity: 0;
vertical-align: middle;
}
.wb_checkbox>input[type="checkbox"]+label {
vertical-align: middle;
border: 2px solid #ccc;
background-color: #fff;
height: 26px;
width: 26px;
margin-right: 16px;
display: inline-block;
z-index: 1;
position: relative;
}
.wb_checkbox>input[type="checkbox"]:checked+label {
background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #65a416), color-stop(1, #6ca43d));
/*background: -moz-linear-gradient(center bottom, #65a416 0%, #6ca43d 100%);*/
box-shadow: 0 2px 7px rgba(0, 0, 0, 0.6);
border: 2px solid #fff;
}
.wb_checkbox>input[type="checkbox"]:checked+label:after {
content: '\2714';
text-indent: 0;
font-size: 15px;
color: #fff;
position: absolute;
top: 2px;
left: 7px;
width: 13px;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-12">
<div class="form-group">
<h5>Choose Option *</h5>
<p class="wb_checkbox">
<input type="checkbox" name="checkbox-1" id="checkbox-1" checked>
<label for="checkbox-1"></label>
<strong>I have not car !</strong>
</p>
<p class="wb_checkbox">
<input type="checkbox" name="checkbox-2" id="checkbox-2">
<label for="checkbox-2"></label>
<strong>I have car</strong>
</p>
</div>
</div>
Related
I'm trying to get a line appear "under" an input box when in focus. For some reason transform-origin "left" (that is if I change it to "right" it will appear from the right side, but with "left" it appears from the left) works but 'bottom' doesn't and it keeps appearing on top.
.wrap-input{
width: 100%;
position: relative;
border-bottom: 2px solid #adadad;
height: 49px;
}
.inputForm {
font-size: 15px;
color: #555555;
line-height: 1.2;
display: block;
width: 100%;
height: 45px;
padding: 0 5px;
outline: none;
border: none;
}
.wrap-input::before{
content: '';
height: 2px;
background: linear-gradient(90deg, rgba(128,0,0,1) 15%, rgba(238,174,150,1) 49%, rgba(128,0,0,1) 85%);
display: block;
transform: scale(0, 1);
transition: transform 0.4s cubic-bezier(1, 0, 0, 1);
transform-origin: left bottom;/*this line is problem*/
}
.wrap-input:hover::before {
transform: scale(1, 1)
}
<div class="wrap-input" data-validate="Valid email is: info#johndoe.com">
<input class="inputForm" type="text" name="email" placeholder="Email">
</div>
I suspect that transform-origin isn't what you require - it tells the system the point from which any tranformation is to take place - it's relative to the element it's in, not to any 'owner'/parent/ancestor.
To position the pseudo element under the input element this snippet gives it position absolute and position left 0 and bottom 0 - these are relative to the actual div itself.
.wrap-input {
width: 100%;
position: relative;
border-bottom: 2px solid #adadad;
height: 49px;
}
.inputForm {
font-size: 15px;
color: #555555;
line-height: 1.2;
display: block;
width: 100%;
height: 45px;
padding: 0 5px;
outline: none;
border: none;
}
.wrap-input::before {
content: '';
height: 2px;
background: linear-gradient(90deg, rgba(128, 0, 0, 1) 15%, rgba(238, 174, 150, 1) 49%, rgba(128, 0, 0, 1) 85%);
display: block;
transform: scale(0, 1);
transition: transform 0.4s cubic-bezier(1, 0, 0, 1);
transform-origin: left center;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
}
.wrap-input:hover::before {
transform: scale(1, 1)
}
<div class="wrap-input" data-validate="Valid email is: info#johndoe.com">
<input class="inputForm" type="text" name="email" placeholder="Email">
</div>
I'm trying to put an opaque layer above an image that also has responsive text on top of it. The opaque layer should be above the image, but below the text, and also not display upon hovering over the image.
My test page is here: https://www.gorgeous-geek.com/image-layer-test/
I tried to add a layer div, but can't find out how to do this to achieve the result I'm looking for.
Also, I don't manage to correctly right align the orange button with the right hand side of the image. It shows up in different places on Chrome and Safari.
Any help appreciated!
This is the code:
.containerbox {
position: relative;
color: white;
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 17.5%;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" style="border: 1px solid #ececec;" alt="Laptop" style="width:100%;">
<div class="top-left">Top Left</div>
<div class="bottom-right">Read more</div>
</div>
</div>
You could use the image filter as shown below. As for the position of the read more button I don't know the result you're looking for.
.containerbox {
position: relative;
}
.containerbox img {
border: 1px solid #ececec;
width: 100%;
filter: opacity(50%);
transition: filter .5s ease-out;
}
.containerbox:hover img {
filter: opacity(100%);
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 17.5%;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" alt="Laptop">
<div class="top-left">Top Left</div>
<div class="bottom-right">
Read more
</div>
</div>
Update
.containerbox {
position: relative;
}
.containerbox img {
border: 1px solid #ececec;
width: 100%;
}
.overlay {
position: absolute;
background: linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%));
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(59%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 0.65)));
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%);
z-index: 1;
height:100%;
top: 0;
left: 0;
width: 100%;
opacity: 100;
transition: opacity .5s ease-out;
}
.containerbox:hover .overlay {
opacity: 0;
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
z-index: 2;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 0;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
z-index: 2;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" alt="Laptop">
<div class="overlay"></div>
<div class="top-left">Top Left</div>
<div class="bottom-right">
Read more
</div>
</div>
You can utilize the z-index property to control the way your elements are layered:
The z-index property specifies the stack order of an element.
An element with greater stack order is always in front of an element with a lower stack order.
Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky).
Source
Below, I created an overlay using the :after psuedo element of .containerbox, and I gave that overlay a z-index: 1. Then, I gave the elements I want to display above my overlay a z-index: 2:
.containerbox {
position: relative;
color: white;
}
.containerbox:after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: white;
opacity: .5;
z-index: 1;
}
.top-left {
position: absolute;
top: 8%;
left: 0;
color: #000;
font-weight: 800;
background-color: #a79f9f;
padding: 6px 40px;
z-index: 2;
}
.bottom-right {
position: absolute;
bottom: 5%;
right: 17.5%;
color: #000;
font-weight: 800;
background: #de9104;
font-size: 14px;
padding: 4px 3%;
z-index: 2;
}
.bottom-right a {
color: white;
}
<div class="containerbox">
<img src="https://www.gorgeous-geek.com/wp-content/uploads/Laptop-on-desk-web-design.jpg" style="border: 1px solid #ececec;" alt="Laptop" style="width:100%;">
<div class="top-left">Top Left</div>
<div class="bottom-right">Read more</div>
</div>
I have created a CSS checkbox. It’s based on a CodePen script I've whittled down, but I can't find how to modify it for a "required" checkbox. The best I can do is to change the color of the box-shadow on "hover", but that's as close as I can get.
Here is what I have:
.checkbox1 {
width: 25px;
margin: 20px 100px;
position: relative;
}
.checkbox1 label {
cursor: pointer;
position: absolute;
width: 16px;
height: 16px;
top: 2px;
left: 3px;
background: linear-gradient(#ffffff, #dddddd 80%);
border: 0.5px solid #7d878d;
border-radius: 4px;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
}
.checkbox1 label:after {
opacity: 0.0;
content: '';
position: absolute;
width: 14px;
height: 6px;
background: transparent;
top: 1px;
left: 2px;
border: 3px solid #ff6600;
border-top: none;
border-right: none;
transform: rotate(-50deg);
}
.checkbox1 label::after {
opacity: 0.0;
}
.checkbox1 input[type=checkbox]:checked+label:after {
opacity: 5;
}
.checkbox2 {
width: 25px;
margin: 20px 100px;
position: relative;
}
.checkbox2 label {
cursor: pointer;
position: absolute;
width: 16px;
height: 16px;
top: 2px;
left: 3px;
background: linear-gradient(#ffffff, #dddddd 80%);
border: 0.5px solid #7d878d;
border-radius: 4px;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
}
.checkbox2 label:after {
opacity: 0.0;
content: '';
position: absolute;
width: 14px;
height: 6px;
background: transparent;
top: 1px;
left: 2px;
border: 3px solid #ff6600;
border-top: none;
border-right: none;
transform: rotate(-50deg);
}
.checkbox2 label::after {
opacity: 0.0;
}
.checkbox2 label:hover {
box-shadow: 0px 0px 4px 0px #ff0000;
opacity: 5;
}
.checkbox2 input[type=checkbox]:checked+label:after {
opacity: 5;
}
<div class="checkbox1">
<input type="checkbox" value="1" id="input1" name="" />
<label for="input1"></label>
</div>
<div class="checkbox2">
<input type="checkbox" value="2" id="input2" name="" required="" />
<label for="input2"></label>
</div>
Use [required] to select the checkbox that has the required attribute, then make your styles based on whether or not it is checked.
I've edited your original code to show this working in the demo below. I've added comments to the CSS to show where I've made the changes.
As you can see, the second checkbox is marked as being "required." Therefore, the [required] initial styles (red box shadow) are applied. Once it is checked, the [required]:checked styles are applied.
.checkbox1 {
width: 25px;
margin: 20px 100px;
position: relative;
}
.checkbox1 label {
cursor: pointer;
position: absolute;
width: 16px;
height: 16px;
top: 2px;
left: 3px;
background: linear-gradient(#ffffff, #dddddd 80%);
border: 0.5px solid #7d878d;
border-radius: 4px;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
}
.checkbox1 label:after {
opacity: 0.0;
content: '';
position: absolute;
width: 14px;
height: 6px;
background: transparent;
top: 1px;
left: 2px;
border: 3px solid #ff6600;
border-top: none;
border-right: none;
transform: rotate(-50deg);
}
.checkbox1 label::after {
opacity: 0.0;
}
.checkbox1 input[type=checkbox]:checked+label:after {
opacity: 5;
}
.checkbox2 {
width: 25px;
margin: 20px 100px;
position: relative;
}
.checkbox2 label {
cursor: pointer;
position: absolute;
width: 16px;
height: 16px;
top: 2px;
left: 3px;
background: linear-gradient(#ffffff, #dddddd 80%);
border: 0.5px solid #7d878d;
border-radius: 4px;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
}
.checkbox2 label:after {
opacity: 0.0;
content: '';
position: absolute;
width: 14px;
height: 6px;
background: transparent;
top: 1px;
left: 2px;
border: 3px solid #ff6600;
border-top: none;
border-right: none;
transform: rotate(-50deg);
}
.checkbox2 label::after {
opacity: 0.0;
}
/* Here, we set the default style of an UNCHECKED REQUIRED checkbox */
.checkbox2 input[type="checkbox"][required]+label {
box-shadow: 0px 0px 4px 0px #ff0000;
opacity: 5;
}
/* Now, we set the style of a CHECK REQUIRED checkbox */
.checkbox2 input[type="checkbox"][required]:checked+label {
box-shadow: 0px 0px 0px 0px transparent !important; /* Remove the box-shadow */
}
.checkbox2 input[type=checkbox]:checked+label:after {
opacity: 5;
}
<div class="checkbox1">
<input type="checkbox" value="1" id="input1" name="" />
<label for="input1"></label>
</div>
<div class="checkbox2">
<input type="checkbox" value="2" id="input2" name="" required="" />
<label for="input2"></label>
</div>
I would like to accomplish the following graphic style with CSS:
I've been able to successfully replicate (approach) every single aspect of the intended design, except for the half-circle cutouts.
The closest I've been able to get is masking out the parts of the node body by setting a background-color for the cutout circles matching that of the backdrop, as well as inset shadows and border on the corresponding side.
After that, I added an extension towards the opposite direction, so that any shadow cast by the node is also effectively masked out. These are the results:
body {
font-family: "Segoe UI";
background-color: #eaeaea;
}
/* --- cutout --- */
.node-cutout-left {
position: absolute;
background-color: #eaeaea;
left: -1px;
width: 18px;
height: 36px;
border-top-right-radius: 50px;
border-bottom-right-radius: 50px;
border: 1px solid rgba(122, 167, 200, 0.7);
border-left: none;
box-shadow: -1px 1px 1px rgba(0,0,0,0.05) inset;
}
.node-cutout-left::after {
content: '';
display: block;
position: absolute;
left: -18px;
top: 0px;
height: 36px;
width: 18px;
background-color: #eaeaea;
}
/* --- end of cutout --- */
.node {
cursor: move;
position: absolute;
top: 12px;
left: 20px;
width: 160px;
box-shadow: 1px 1px 5px rgba(0,0,0,0.25);
border: 1px solid rgba(122, 167, 200, 0.7);
}
.node-header {
min-height: 20px;
padding: 6px 12px;
background-color: #489ddb;
color: #fff;
font-size: 12pt;
font-weight: 100;
box-shadow: 0px 0px 0px 1px #489ddb; /* overlay node-border */
}
.node-body {
position: relative;
min-height: 100px;
padding: 12px 24px;
background: #ffffff;
background: linear-gradient(170deg, #ffffff 0%,#e5e5e5 100%);
border: 1px solid rgba(255,255,255,0.5);
}
<div class="node" draggable="true" ondragstart="console.log(event);">
<div class="node-header">
<div class="node-title">Gain</div>
</div>
<div class="node-body">
<div class="node-cutout-left" style="top:20px;"></div>
<div class="node-cutout-left" style="top:70px;"></div>
</div>
</div>
However, I need transparent background in the masked out area. How could I accomplish this?
I've also prepared a JSFiddle (illustrating the problem) for those who'd wish to join this brainstorm, and whose help I would appreciate beyond measure.
Questions already on SO failed to solve my issue so far, as they use either the box-shadow of the element used as the cutout to fill the rendered area of the clipped element (which would cancel out the gradient background in my case)...
... or SVG clips, for which I -- for the life of it -- can't find a working example when applied to HTML elements with bordered style.
Ok, here you are. Probably it can be achieved in less code, but it's a start.
Only the gradient is a small issue..
body {
font-family: "Segoe UI";
background-color: #ccc;
}
* {
box-sizing: border-box;
}
.node {
cursor: move;
position: absolute;
top: 40px;
left: 60px;
width: 180px;
}
.node-header {
min-height: 20px;
padding: 6px 12px;
background-color: #489ddb;
color: #fff;
font-size: 12pt;
font-weight: 100;
}
.node-body {
position: relative;
min-height: 100px;
padding-left: 19px;
}
.node-content {
padding: 12px 24px;
background: #fff;
background: linear-gradient(170deg, #ffffff 0%, #e5e5e5 100%);
width: 100%;
border: 1px solid rgba(122, 167, 200, 0.7);
border-left: none;
border-top: none;
min-height: 145px;
}
.node-cutout {
overflow: hidden;
width: 19px;
position: absolute;
left: 0;
top: 0;
height:200px;
}
.node-square {
position: absolute;
border-left: 1px solid rgba(122, 167, 200, 0.7);
border-bottom: 1px solid rgba(122, 167, 200, 0.7);
width: 19px;
height: 18px;
z-index: 1;
background-color:#eaeaea;
}
.round {
padding: 18px;
position: relative;
overflow: hidden;
display: block;
width: 0px;
}
.round:before {
content: '';
position: absolute;
width: 35px;
height: 35px;
border: 1px solid rgba(122, 167, 200, 0.7);
border-radius: 100%;
box-shadow: 0 0 0 200px #eaeaea;
z-index: 1
}
.round:after {
background-color: rgba(122, 167, 200, 0.7);
content: '';
position: absolute;
left: 0;
width:1px;
z-index: 1;
height: 18px;
display: inline-block;
}
.round.top:after {
margin-top: -18px;
}
.round.top:before {
left: -18px;
}
.round.bottom:before {
left: -18px;
top: -18px;
}
<div class="node" draggable="true" ondragstart="console.log(event);">
<div class="node-header">
<div class="node-title">Gain</div>
</div>
<div class="node-body">
<div class="node-content">
</div>
<div class="node-cutout">
<div class="node-cutout-left" style="">
<span class="round top"></span>
<span class="round bottom"></span>
</div>
<div class="node-cutout-left" style="margin-top:-17px;">
<span class="round top"></span>
<span class="round bottom"></span>
</div>
<div class="node-square">
</div>
</div>
</div>
</div>
Please try this:
<div class="node" draggable="true" ondragstart="console.log(event);">
<div class="node-header">
<div class="node-title">Gain</div>
</div>
<div class="node-body">
<i class="fa fa-volume-up fa_custom"></i>
<div class="node-cutout-left" style="top:20px;"></div>
<div class="node-cutout-left" style="top:70px;"></div>
</div>
</div>
CSS:
body {
font-family: "Segoe UI";
}
.fa_custom{position: absolute;
left: -11px;
z-index: 1000000;
color: #fff;
top: 32px;}
.node {
cursor: move;
position: absolute;
top: 40px;
left: 60px;
width: 180px;
border: 1px solid rgba(122, 167, 200, 0.7);
box-shadow: 1px 1px 5px rgba(0,0,0,0.25);
}
.node-header {
min-height: 20px;
padding: 6px 12px;
background-color: #489ddb;
color: #fff;
font-size: 12pt;
font-weight: 100;
}
.node-body {
position: relative;
min-height: 100px;
padding: 12px 24px;
background: #ffffff;
}
.node-cutout-left {
position: absolute;
background-color: #eaeaea;
left: -1px;
width: 18px;
height: 36px;
border-top-right-radius: 50px;
border-bottom-right-radius: 50px;
border: 1px solid rgba(122, 167, 200, 0.7);
border-left: none;
box-shadow: -1px 1px 1px rgba(0,0,0,0.05) inset;
}
.node-cutout-left::after {
content: '';
display: block;
position: absolute;
left: -19px;
top: 3px;
height: 30px;
width: 33px;
border-radius: 64%;
background-color: #489DDB;
}
JSFiddle Link: https://jsfiddle.net/jdqht5ch/
So I am trying to change the border of a rounded checkbox I have in my code. I want to make the border thinner.
.roundedOne {
width: 28px;
height: 28px;
position: absolute;
left: 0px;
top: 1100px;
background: white;
background: -webkit-linear-gradient(top, white 0%, black 0%, black 80%);
background: linear-gradient(to bottom, white 0%, black 0%, black 80%);
border-radius: 100px;
}
.roundedOne label {
width: 20px;
height: 20px;
cursor: pointer;
position: absolute;
left: 4px;
top: 4px;
background: white;
border-radius: 100px;
box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px white;
}
.roundedOne label:after {
content: '';
width: 16px;
height: 16px;
position: absolute;
top: 2px;
left: 2px;
background: #19B5FE;
opacity: 0;
border-radius: 100px;
}
.roundedOne label:hover::after {
opacity: 0;
}
.roundedOne input[type=checkbox] {
visibility: hidden;
}
.roundedOne input[type=checkbox]:checked + label:after {
opacity: 1;
}
<div class="roundedOne">
<input type="checkbox" value="None" id="roundedOne" name="check" checked />
<label for="roundedOne"></label>
</div>
How can I make the outside border which is black, thinner?
Also how can I change it because now when I enter the page it is already filled, I want it to be unfilled when someone enters page.
Here is what I want:
Change width/height of your .roundedOne (which updated to just a single div) then change top/left to center the input within the background black.
Remove checked in HTML to not be checked when you enter the page.
body {
background: gray;
margin: 0
}
div {
width: 26px;
height: 27px;
position: relative;
left: 0;
/*top: 1100px; */
background: white;
background: -webkit-linear-gradient(top, white 0%, black 0%, black 80%);
background: linear-gradient(to bottom, white 0%, black 0%, black 80%);
border-radius: 100px;
}
label {
width: 20px;
height: 20px;
cursor: pointer;
position: absolute;
left: 3px;
top: 3px;
background: white;
border-radius: 100px;
box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 1px 0px white;
}
label:after {
content: '';
width: 16px;
height: 16px;
position: absolute;
top: 2px;
left: 2px;
background: #19B5FE;
opacity: 0;
border-radius: 100px;
}
span {
display: inline-block;
margin-left: 30px;
min-width:100px
}
label:hover::after {
opacity: 0;
}
input[type=checkbox] {
visibility: hidden;
}
input[type=checkbox]:checked + label:after {
opacity: 1;
}
<div>
<input type="checkbox" value="None" id="roundedOne" name="check" />
<label for="roundedOne">
<span>Checkbox 1</span>
</label>
</div>
<div>
<input type="checkbox" value="None" id="roundedTwo" name="check" />
<label for="roundedTwo">
<span>Checkbox 2</span>
</label>
</div>
<div>
<input type="checkbox" value="None" id="roundedThree" name="check" />
<label for="roundedThree">
<span>Checkbox 3</span>
</label>
</div>
<div>
<input type="checkbox" value="None" id="roundedFour" name="check" />
<label for="roundedFour"><span>Checkbox 4</span>
</label>
</div>