How to remove jagged border when using radial-gradient - css

I found this nice button on CodePen that inverts the button color with a ripple effect, using a radial-gradient animation.
I need it to have a 28px border radius, but then a jagged border appears as shown here.
html {
box-sizing: border-box;
height: 100%;
font-size: 10px;
}
*, *::before, *::after {
box-sizing: inherit;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #57bd84;
}
input[type=checkbox] {
height: 0;
width: 0;
visibility: hidden;
}
input[type=checkbox]:checked + label:after {
transform: scale(4.2);
}
label {
outline: none;
user-select: none;
color: #000;
font-family: 'Lato', sans-serif;
font-size: 2.5rem;
letter-spacing: 0.04rem;
padding: 1.5rem 3rem;
cursor: pointer;
border-radius: 28px;
border: 0.3rem solid #000;
background: #fff;
position: relative;
overflow: hidden;
box-shadow: 0 3px 0 0 #000;
}
label::after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
transform: scale(0);
transition: transform 0.3s ease-in;
mix-blend-mode: difference;
background: radial-gradient(circle at center, #fff 24%, #000 25%, #000 100%);
}
label:active {
top: 3px;
box-shadow: none;
}
<input type="checkbox" id="cb1" /><label for="cb1">Toggle me</label>

I would do it differently using the other pseudo element where I will have the border to avoid this bad effect. I will also replace the scale transition with a background-size effect
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-size: 10px;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #57bd84;
margin:0;
}
input[type=checkbox] {
height: 0;
width: 0;
visibility: hidden;
}
label {
outline: none;
user-select: none;
color: #000;
font-family: 'Lato', sans-serif;
font-size: 2.5rem;
letter-spacing: 0.04rem;
padding: 1.5rem 3rem;
cursor: pointer;
border-radius: 28px;
background: #fff;
position: relative;
}
label::before,
label::after{
content: '';
position: absolute;
border-radius: inherit;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
label::after {
border:3px solid #000;
box-shadow:0 3px 0 0 #000;
}
label::before {
mix-blend-mode: difference;
background:
radial-gradient(circle at center, #fff 24%, #000 25%, #000 100%)
center/0% 0% no-repeat;
transition: background-size 0.3s ease-in;
}
input[type=checkbox]:checked+label:before {
background-size:400% 400%;
}
label:active {
transform:translateY(3px);
}
label:active::after {
box-shadow:0 0 0 0 #000;
}
<input type="checkbox" id="cb1" /><label for="cb1">Toggle me</label>

Related

Is there a way to make a 10-20px line curve with a bigger containers border radius?

Without a border radius, when hovered, the line extends and connects like the middle button so:
With a border radius:
If I try to add a border radius and match it the smaller borders:
Does anyone know how you would make the small borders follow the same curve?
.barChart__button {
position: relative;
width: 300px;
height: 60px;
color: white;
border: none;
background-color: #272A2F;
border-radius: 20px;
font-family: 'Roboto';
font-size: 28px;
font-weight: 700;
margin-bottom: 34px;
transition: 0.5s;
overflow: hidden;
}
.barChart__button::before {
content: '';
position: absolute;
top: 5px;
left: 5px;
width: 10px;
height: 10px;
border-top: 2px solid #c3a5ff;
border-left: 2px solid #c3a5ff;
transition: 0.5s;
border-radius: 5px;
}
.barChart__button:hover:before,
.barChart__button:hover:after {
width: 100%;
height: 100%;
}
.barChart__button::after {
content: '';
position: absolute;
bottom: 5px;
right: 5px;
width: 10px;
height: 10px;
border-bottom: 2px solid #c3a5ff;
border-right: 2px solid #c3a5ff;
transition: 0.5s;
border-radius: 5px;
}
<div className='barChart__buttonContainer'>
<button class='barChart__button'>Remaining hours</button>
<button class='barChart__button'>Requests by user</button>
<button class='barChart__button'>Other example</button>
</div>
```
Here is an idea using mask:
.barChart__button {
color: white;
border: none;
background-color: #272A2F;
font-size: 20px;
font-weight: bold;
padding: 10px 20px;
border-radius: 10px; /* your radius */
position: relative;
z-index: 0;
}
.barChart__button:before {
content: "";
position: absolute;
z-index: -1;
inset: 0;
border-radius: inherit;
padding: 2px; /* border thickness here */
--g: linear-gradient(#c3a5ff 0 0) no-repeat; /* the color here */
background: var(--g) 0 0, var(--g) 100% 100%;
background-size: 10px 10px; /* initial size here */
-webkit-mask:
linear-gradient(#000 0 0) content-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
transition: .5s;
}
.barChart__button:hover:before {
background-size: 100% 100%;
}
body {
background-color: black;
}
<button class='barChart__button'>Remaining hours</button>
<button class='barChart__button'>Requests by user</button>
Also like below if your background will always be a solid coloration:
.barChart__button {
border: 2px solid #0000; /* border thickness here */
/* the border color below */
--g: linear-gradient(#c3a5ff 0 0) no-repeat border-box;
background:
linear-gradient(#272A2F 0 0) padding-box,
var(--g) 0 0 /var(--s,10px 10px),
var(--g) 100% 100%/var(--s,10px 10px),
#272A2F;
border-radius: 10px; /* your radius */
transition:.5s;
color: white;
font-size: 20px;
font-weight: bold;
padding: 10px 20px;
}
.barChart__button:hover {
--s: 100% 100%;
}
body {
background-color: black;
}
<button class='barChart__button'>Remaining hours</button>
<button class='barChart__button'>Requests by user</button>

The “before” and “after” pseudo-elements are overlapped by wrapper div on the active state

I have created the button which needs border with gradient, in order to do that I have used pseudo-elements "before" and "after"(before with gradient and after with white background color witch overlap before, ordered by z-index). The problem is that when a wrapper div has a background color, the buttons pseudo elements are getting overlapped on the active state! This can be fixed by adding z-index to 0 or 1 to wrapper div... but still, I don't like this workaround! Thanks!
https://jsfiddle.net/x0uw5et3/1/enter code here
Edit wrapper-of-wrapper class to following
.wrapper-of-wrapper {
background-color: purple;
position:relative;
z-index:-2;
}
Hey Here I have your solution your fiddle here
.wrapper-of-wrapper {
background-color: purple;
position: relative;
z-index: 1;
}
body {
background: orange;
}
.wrapper {
/* background-color: orange; */
}
.wrapper-of-wrapper {
background-color: purple;
position: relative;
z-index: 1;
}
.sf-btn {
font-family: Poppins, Helvetica Neue, Helvetica, Arial, sans-serif;
display: inline-block;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border-radius: 4px;
line-height: 24px;
border: 0;
padding: 8px 16px;
width: 100%;
-webkit-transition: all .4s cubic-bezier(.25, .8, .25, 1);
transition: all .4s cubic-bezier(.25, .8, .25, 1);
-webkit-transition: none;
transition: none;
}
.sf-btn:focus, .sf-btn:hover {
color: #fff;
}
.sf-btn:active, .sf-btn:focus, .sf-btn:hover {
color: #fff;
}
#media (min-width: 640px) {
.sf-btn {
width: auto;
}
}
.sf-btn svg {
fill: inherit;
}
.sf-btn--secondary {
z-index: 3;
color: #262a33;
position: relative;
background-color: #fff;
font-weight: 600;
outline: none;
}
.sf-btn--secondary::before {
background: -webkit-gradient(linear, left top, right top, from(red), color-stop(50%, red), to(#ff7000));
background: linear-gradient(90deg, red, red 50%, #ff7000);
content: "";
position: absolute;
z-index: -2;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 4px;
}
.sf-btn--secondary::after {
content: "";
position: absolute;
background-color: #fff;
border-radius: 4px;
z-index: -1;
top: 2px;
left: 2px;
right: 2px;
bottom: 2px;
}
.sf-btn--secondary:hover {
color: #262a33;
}
.sf-btn--secondary:hover::before {
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
}
.sf-btn--secondary:focus {
color: #262a33;
}
.sf-btn--secondary:focus::before {
z-index: -2;
-webkit-box-shadow: 0 0 6px 2px #ff7000;
box-shadow: 0 0 6px 2px #ff7000;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.sf-btn--secondary:active {
z-index: inherit;
background: linear-gradient(34deg, #eb2506, #eb2506 37%, #ef6f08);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.sf-btn--secondary:active::after {
z-index: -2;
}
.sf-btn--secondary:active::before {
-webkit-box-shadow: none;
box-shadow: none;
}
.sf-btn--lg {
padding: 8px 64px;
font-size: 16px;
line-height: 48px;
font-weight: 700;
}
.sf-btn--full-width {
width: 100%;
margin-right: -4px!important;
}
.sf-btn--full-width::after {
transform: translateX(4px);
}
.wrapper--red {
background-color: red;
z-index: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrapper-of-wrapper">
<div class="wrapper">
<button class="sf-btn sf-btn--lg sf-btn--secondary">Hello</button>
</div>
</div>

How to modify CSS float label on per input basis

In my project I am using some CSS code to create a floating label for my form inputs. The original code for the floating label can be found here for reference.
However since this code contains a number of floating label examples I have extracted the compiled CSS for the one I am interested in (balloon) and created an example below with my modifications. Specifically I have added a value to the input fields.
.balloon {
display: inline-block;
width: 600px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px;
transition: all .3s ease-in-out;
}
.balloon::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}
.balloon + label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122, 184, 147, 0);
}
.balloon + label:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122, 184, 147, 0);
transition: all .3s ease-in-out;
}
.balloon:focus,
.balloon:active {
color: #377D6A;
text-indent: 0;
background: #fff;
}
.balloon:focus::-webkit-input-placeholder,
.balloon:active::-webkit-input-placeholder {
color: #aaa;
}
.balloon:focus + label,
.balloon:active + label {
color: #fff;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #7ab893;
transform: translateY(-40px);
}
.balloon:focus + label:after,
.balloon:active + label:after {
border-top: 4px solid #7ab893;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
position: relative;
z-index: 1;
text-align: center;
}
.row:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
background: inherit;
}
.row:first-child {
padding: 40px 30px;
}
.row span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
<div class="row">
<span>
<input class="balloon" id="state" type="text" value="AR" placeholder="Liquid, solid, gaseous..." /><label for="state">State</label>
</span>
<span>
<input class="balloon" id="planet" value="Earth" type="text" placeholder="Probably Earth" /><label for="planet">Planet</label>
</span>
<span>
<input class="balloon" id="galaxy" type="text" value="This is a test" placeholder="Milky Way?" /><label for="galaxy">Guardians of the Galaxy</label>
</span>
</div>
The question I have, if you look at the third input, is how to adjust spacing for the label so they dont overlap. I realize that I can change the text-indent in the balloon class but that will change the spacing for all the inputs.
Is there a way on an individual basis I can adjust the spacing to account for different lengths in labels?
Add an extra class to "Gardians" and style that to have a little more with.
Then (and I can't believe I'm about to say this) use !important on the active text-indent to overcome the extra specificity of the new class.
.balloon {
display: inline-block;
width: 600px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px;
transition: all .3s ease-in-out;
}
/*Wide Version - can be applied to more elements*/
.balloon.wide {
text-indent: 200px;
}
.balloon::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}
.balloon + label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122, 184, 147, 0);
}
.balloon + label:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122, 184, 147, 0);
transition: all .3s ease-in-out;
}
.balloon:focus,
.balloon:active {
color: #377D6A;
/*Note !important*/
text-indent: 0 !important;
background: #fff;
}
.balloon:focus::-webkit-input-placeholder,
.balloon:active::-webkit-input-placeholder {
color: #aaa;
}
.balloon:focus + label,
.balloon:active + label {
color: #fff;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #7ab893;
transform: translateY(-40px);
}
.balloon:focus + label:after,
.balloon:active + label:after {
border-top: 4px solid #7ab893;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
position: relative;
z-index: 1;
text-align: center;
}
.row:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
background: inherit;
}
.row:first-child {
padding: 40px 30px;
}
.row span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
<div class="row">
<span>
<input class="balloon" id="state" type="text" value="AR" placeholder="Liquid, solid, gaseous..." /><label for="state">State</label>
</span>
<span>
<input class="balloon" id="planet" value="Earth" type="text" placeholder="Probably Earth" /><label for="planet">Planet</label>
</span>
<span>
<input class="balloon wide" id="galaxy" type="text" value="This is a test" placeholder="Milky Way?" /><label for="galaxy">Guardians of the Galaxy</label>
</span>
</div>
I normally avoid !important like the plague but in this case it makes sense. You could avoid it by using more specific selectors for your active state
.balloon:focus,
.balloon:active,
.balloon.wide:focus,
.balloon.wide:active, {
color: #377D6A;
text-indent: 0;
background: #fff;
}
target the input value
input[value="This is a test"] {text-indent:170px; }
.balloon {
display: inline-block;
width: 600px;
padding: 10px 0 10px 15px;
font-family: "Open Sans", sans;
font-weight: 400;
color: #377D6A;
background: #efefef;
border: 0;
border-radius: 3px;
outline: 0;
text-indent: 60px;
transition: all .3s ease-in-out;
}
.balloon::-webkit-input-placeholder {
color: #efefef;
text-indent: 0;
font-weight: 300;
}
.balloon + label {
display: inline-block;
position: absolute;
top: 8px;
left: 0;
bottom: 8px;
padding: 5px 15px;
color: #032429;
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0);
transition: all .3s ease-in-out;
border-radius: 3px;
background: rgba(122, 184, 147, 0);
}
.balloon + label:after {
position: absolute;
content: "";
width: 0;
height: 0;
top: 100%;
left: 50%;
margin-left: -3px;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
border-top: 3px solid rgba(122, 184, 147, 0);
transition: all .3s ease-in-out;
}
.balloon:focus,
.balloon:active {
color: #377D6A;
text-indent: 0;
background: #fff;
}
.balloon:focus::-webkit-input-placeholder,
.balloon:active::-webkit-input-placeholder {
color: #aaa;
}
.balloon:focus + label,
.balloon:active + label {
color: #fff;
text-shadow: 0 1px 0 rgba(19, 74, 70, 0.4);
background: #7ab893;
transform: translateY(-40px);
}
.balloon:focus + label:after,
.balloon:active + label:after {
border-top: 4px solid #7ab893;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700,600,300,800);
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #fff;
background: #efefef;
}
.row {
max-width: 800px;
margin: 0 auto;
padding: 60px 30px;
background: #032429;
position: relative;
z-index: 1;
text-align: center;
}
.row:before {
position: absolute;
content: "";
display: block;
top: 0;
left: -5000px;
height: 100%;
width: 15000px;
z-index: -1;
background: inherit;
}
.row:first-child {
padding: 40px 30px;
}
.row span {
position: relative;
display: inline-block;
margin: 30px 10px;
}
<div class="row">
<span>
<input class="balloon" id="state" type="text" value="AR" placeholder="Liquid, solid, gaseous..." /><label for="state">State</label>
</span>
<span>
<input class="balloon" id="planet" value="Earth" type="text" placeholder="Probably Earth" /><label for="planet">Planet</label>
</span>
<span>
<input class="balloon" id="galaxy" type="text" value="This is a test" placeholder="Milky Way?" /><label for="galaxy">Guardians of the Galaxy</label>
</span>
</div>

How to do this kind of Button in CSS?

I've been searching the Internet for a while and found nothing, so I'm turning to you guys.
I was wondering how you can do a button like this with CSS (On/Off button example):
I already tried something like this :
HTML :
<a class="button_tooltip" href="#">On</a>
<a class="button_tooltip" href="#">Off</a>
CSS:
a {
color: #76daff;
display: inline-block;
padding: 8px 16px;
position: relative;
text-decoration: none;
}
a {
color: #76daff;
}
a.button_tooltip {
background: #ccc none repeat scroll 0 0;
color: black;
}
a.button_tooltip::after {
border-top-color: #cccccc;
}
a.button_tooltip::after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ccc;
content: "";
margin-left: -8px;
}
a.button_tooltip {
background: #cccccc none repeat scroll 0 0;
color: #000000;
}
a.button_tooltip::after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ccc;
content: "";
}
a.button_tooltip::after {
border-top-color: #cccccc;
}
But only gave me the square without the little triangle underneath.
This is easily possible with 2 elements and using a pseudo element to get the arrow bit underneath to show.
It doesn't take a great deal of HTML/CSS to complete and can easily be changed to work as an input or as an <a> tag. Whatever your requirements are.
$(document).ready(function() {
$('.btn').click(function() {
$('.btn').toggleClass('active');
});
});
.container {
width: 200px;
height: 100px;
}
.btn {
width: 100px;
height: 100px;
box-sizing: border-box;
border: 1px solid blue;
float: left;
cursor: pointer;
}
.active {
background: blue;
position: relative;
}
.active:before {
content: '';
position: absolute;
width: 50px;
height: 50px;
transform: rotate(45deg);
bottom: -10px;
left: 25px;
background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="btn"></div>
<div class="btn active"></div>
</div>
$(document).ready(function() {
$('.toggle-btn button').click(function() {
$(this).parent('.toggle-btn').children('button').removeClass('active');
$(this).addClass('active');
});
});
.toggle-btn {
border: 1px solid #4c8cca;
display: inline-block;
line-height: 1;
width: 100px;
}
button {
line-height: 1;
float: left;
height: 30px;
background: none;
background-color: transparent;
border: none;
padding: 0;
position: relative;
outline: 0;
width: 50%;
cursor: pointer;
}
button:hover {
background-color: #EEE;
}
button.active {
background: #4c8cca;
background-color: #4c8cca;
color: #FFF;
}
button.active:after {
content: '';
position: absolute;
width: 10px;
height: 10px;
top: 25px;
transform: rotate(45deg);
background-color: #4c8cca;
left: 50%;
margin-left: -4px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle-btn">
<button>Yes</button>
<button class="active">No</button>
</div>
Here you go:
http://jsfiddle.net/es_kaija/negzqemp/
<div class="switch off">
<div class="toggle"></div>
<span class="on">ON</span>
<span class="off">OFF</span>
</div>
<style>
.switch {
position: relative;
display: inline-block;
font-size: 1em;
font-weight: bold;
color: #ccc;
text-shadow: 0px 1px 1px rgba(255,255,255,0.8);
height: 18px;
padding: 6px 6px 5px 6px;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,0.2);
border-radius: 4px;
background: #ececec;
box-shadow: 0px 0px 4px rgba(0,0,0,0.1), inset 0px 1px 3px 0px rgba(0,0,0,0.1);
cursor: pointer;
}
.switch span { display: inline-block; width: 35px; }
.switch span.On { color: #33d2da; }
.switch .toggle {
position: absolute;
top: 1px;
width: 37px;
height: 25px;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,0.3);
border-radius: 4px;
background: #fff;
background: -moz-linear-gradient(top, #ececec 0%, #ffffff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ececec), color-stop(100%,#ffffff));
background: -webkit-linear-gradient(top, #ececec 0%,#ffffff 100%);
background: -o-linear-gradient(top, #ececec 0%,#ffffff 100%);
background: -ms-linear-gradient(top, #ececec 0%,#ffffff 100%);
background: linear-gradient(top, #ececec 0%,#ffffff 100%);
box-shadow: inset 0px 1px 0px 0px rgba(255,255,255,0.5);
z-index: 999;
-webkit-transition: all 0.15s ease-in-out;
-moz-transition: all 0.15s ease-in-out;
-o-transition: all 0.15s ease-in-out;
-ms-transition: all 0.15s ease-in-out;
}
.switch.on .toggle { left: 2%; }
.switch.off .toggle { left: 54%; }
</style>
<script>
$(document).ready(function() {
// Switch toggle
$('.switch').click(function() {
$(this).toggleClass('on').toggleClass('off');
});
});
</script>
You can do that using css itself. Here is the example - https://jsfiddle.net/p653bpbe/
html
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
css
.onoffswitch {
position: relative; width: 90px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 1px solid #2E8DEF; border-radius: 0px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 26px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
border: 2px solid transparent;
background-clip: padding-box;
}
.onoffswitch-inner:before {
content: "";
padding-left: 10px;
background-color: #FFFFFF; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "";
padding-right: 10px;
background-color: #FFFFFF; color: #333333;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 45px; margin: 0px;
background: #2E8DEF;
position: absolute; top: 0; bottom: 0;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
Button
a { font-size: 0; line-height: 0; text-indent: -4000px; background: #fff; border: 1px solid #007bff; width: 30px; height: 30px; display: block; position: relative; }
a:after { position: absolute; top: -1px; left: 30px; width: 30px; height: 30px; content: ''; display: block; background: #007bff; border: 1px solid #007bff; }
a:before { content: ''; display: block; width: 0; height: 0; border-style: solid; border-width: 10px 10px 0 10px; border-color: #007bff transparent transparent transparent; position: absolute; bottom: -10px; right: -25px; }

Div is not full width without putting the main div over the next?

I am working on a project where I am making two divs that are full width the main one comes first and the second div comes after the main div.
Main Div CSS:
*{
margin:0px;
padding:0px;
}
div.main{
top: -100px;
/*background: url(img/bg.jpg) no-repeat center center fixed #000000;*/
/*background: url(http://www.deliciousfood4u.com/wp-content/uploads/2012/05/food_steak_desktop_1302x1020_wallpaper-420339.jpg) no-repeat center center fixed #324a6f;*/
background-size: cover;
background-repeat: no-repeat;
margin-left: -1px;
position: absolute;
}
html, body, .main, #wrappertwo { height: 100%; min-height: 100%; }
.main { margin: 0 auto; oveflow: hidden; width: 100%; background-color: gray;}
I would like my end website to work similar to this website here: http://www.whitmansnyc.com/
You can see all the code here: http://jsfiddle.net/QFRB8/
Here you go, I'm sure you will have much better use than me. Just edit the box in there and delete it to have a full width with main and second div.
http://jsfiddle.net/tS9fX/
html:
<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Blah</title>
<link type="text/css" rel="stylesheet" media="all" href=
"style.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css.css" />
<link type="text/css" rel="stylesheet" media="screen" href="css_002.css" />
</head>
<body class="user_suscriptions index">
<div id="wrapper">
<h1 class="logo">Title</h1>
<h2>another title</h2>
<div class="field form_suscription">
<form novalidate="novalidate" method="post" id="new_user_suscription" data-remote=
"true" class="simple_form new_user_suscription" action="/user_suscriptions"
accept-charset="UTF-8" name="new_user_suscription">
<div style="margin:0;padding:0;display:inline">
<input type="hidden" value="✓" name="utf8" /> <input type="hidden"
value="1Oz4NpXl188INQoGZkqy4LaItW/6sxtsNNruWFBJQEM=" name=
"authenticity_token" />
</div>
<div class="error_message"></div>
<div class="input email required user_suscription_email">
<input type="email" size="50" placeholder="Your email address ;)" name=
"user_suscription[email]" id="user_suscription_email" class=
"string email required left" autofocus="autofocus" />
</div><input type="submit" value="Subscribe!" name="commit" class=
"btn green-btn" />
</form>
<div class="clear"></div><small>blahb</small>
</div>
<div class="clear"></div>
<div class="content">
<div class="left">
<h2 class="logo">test subject</h2>
</div>
<div class="right">
<h2>Blah title.</h2>
<p>Blah</p>
</div>
<div class="clear"></div>
</div>
<div class="content">
<div class="block">
<h3>blag</h3>
<p>blag</p>
</div>
<div class="block">
<h3>blag</h3>
<p>blag</p>
</div>
<div class="block">
<h3>blag</h3>
<p>blag</p>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</body>
</html>
CSS:
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
audio,
canvas,
video {
display: inline-block;
}
audio:not([controls]) {
display: none;
height: 0;
}
[hidden] {
display: none;
}
html {
font-family: sans-serif; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
body {
margin: 0;
}
a:focus {
outline: thin dotted;
}
a:active,
a:hover {
outline: 0;
}
h1 {
font-size: 2em;
}
abbr[title] {
border-bottom: 1px dotted;
}
b,
strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
mark {
background: #ff0;
color: #000;
}
code,
kbd,
pre,
samp {
font-family: monospace, serif;
font-size: 1em;
}
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
q {
quotes: "\201C" "\201D" "\2018" "\2019";
}
small {
font-size: 80%;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0;
}
svg:not(:root) {
overflow: hidden;
}
figure {
margin: 0;
}
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
button,
input,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 2 */
margin: 0; /* 3 */
}
button,
input {
line-height: normal;
}
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
button[disabled],
input[disabled] {
cursor: default;
}
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
input[type="search"] {
-webkit-appearance: textfield; /* 1 */
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box; /* 2 */
box-sizing: content-box;
}
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
textarea {
overflow: auto; /* 1 */
vertical-align: top; /* 2 */
}
table {
border-collapse: collapse;
border-spacing: 0;
}
body {
font: 14px "Lato", sans-serif;
background: url(http://i.imgur.com/oRLPdXl.jpg) no-repeat center center fixed;
background-size: cover;
color: #FFF; }
#bgMax {
min-height: 100%;
min-width: 1400px;
width: 100%;
height: auto;
position: fixed;
top: 0;
left: 0; }
a {
text-decoration: none;
color: white; }
p {
font-size: 16px;
line-height: 30px; }
li {
list-style: none; }
.clear {
clear: both;
visibility: hidden; }
.bgFade {
background-color: white; }
input[type="text"], input[type="email"] {
border: none;
padding: 14px;
font-size: 16px;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px; }
input[type="text"]:focus, input[type="email"]:focus {
border-color: red;
outline: none; }
.green-btn {
background: url("http://printgram.noflagra.com/wp-content/themes/Printgram/css/images/comofunciona-bg.png") repeat scroll 0 0 transparent;
color: white;
padding: 16px;
font-weight: bold;
display: inline-block;
width: initial;
border: none;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
transition: 0.2s all ease-out;
-webkit-transition: 0.2s all ease-out;
-moz-transition: 0.2s all ease-out;
-o-transition: 0.2s all ease-out; }
.green-btn:hover {
background: #34da97; }
.green-btn:active {
background: #08b16d; }
::-webkit-scrollbar {
width: 15px;
margin-left: 10px;
background: white;
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.25); }
::-webkit-scrollbar-thumb {
border: solid 0 transparent;
border-right-width: 3px;
border-left-width: 4px;
-webkit-border-radius: 9px 6px;
-webkit-box-shadow: inset 0 0 0 1px #a1a1a1, inset 0 0 0 6px #a1a1a1; }
::-webkit-scrollbar-thumb:hover {
-webkit-box-shadow: inset 0 0 0 1px gray, inset 0 0 0 6px gray; }
::-webkit-scrollbar-track-piece {
background: transparent none;
border: solid 4px transparent;
border-right-width: 8px;
margin: 4px; }
#-webkit-keyframes fadeInUp {
0% {
opacity: 0;
-webkit-transform: translateY(30px); }
100% {
opacity: 1;
-webkit-transform: translateY(0); } }
#-moz-keyframes fadeInUp {
0% {
opacity: 0;
-moz-transform: translateY(30px); }
100% {
opacity: 1;
-moz-transform: translateY(0); } }
#-o-keyframes fadeInUp {
0% {
opacity: 0;
-o-transform: translateY(30px); }
100% {
opacity: 1;
-o-transform: translateY(0); } }
#keyframes fadeInUp {
0% {
opacity: 0;
transform: translateY(30px); }
100% {
opacity: 1;
transform: translateY(0); } }
#-webkit-keyframes fadeIn {
0% {
opacity: 0; }
100% {
opacity: 1; } }
#-moz-keyframes fadeIn {
0% {
opacity: 0; }
100% {
opacity: 1; } }
#-o-keyframes fadeIn {
0% {
opacity: 0; }
100% {
opacity: 1; } }
#keyframes fadeIn {
0% {
opacity: 0; }
100% {
opacity: 1; } }
.logo {
font-family: "Pacifico", cursive;
color: white;
font-weight: normal;
margin: 0; }
.content {
width: 1000px;
margin: 0 auto;
padding: 100px 0px; }
.left {
float: left; }
.right {
float: right; }
header .content {
padding: 0; }
header .language {
float: right;
margin-top: 15px; }
header .language .social {
float: left;
margin-right: 10px; }
header .language .social .fb, header .language .social .tw {
float: left;
margin: 0 5px; }
header .language .select {
float: left;
background: white;
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
padding: 1px 9px; }
header .language .select a {
font-weight: bold;
font-size: 12px;
color: #999999; }
.info {
animation: fadeInUp 1s 1;
-moz-animation: fadeInUp 1s 1;
-webkit-animation: fadeInUp 1s 1;
-o-animation: fadeInUp 1s 1;
width: 910px;
margin: 0 auto;
padding: 120px 0px 190px 0px;
text-align: center; }
.info small {
color: white;
display: block;
font-size: 15px;
margin: 5px;
text-shadow: 0px 1px 1px #353535;
-webkit-text-shadow: 0px 1px 1px #353535;
-o-text-shadow: 0px 1px 1px #353535;
-moz-text-shadow: 0px 1px 1px #353535; }
.info .logo {
font-size: 70px; }
.info h2 {
color: white;
font-size: 30px;
font-weight: 300;
text-align: center;
margin: 40px 0px;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
-webkit-text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
-o-text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
-moz-text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3); }
.info .field {
margin: 50px 0px 10px 0px;
animation: fadeInUp 1s 1;
-moz-animation: fadeInUp 1s 1;
-webkit-animation: fadeInUp 1s 1;
-o-animation: fadeInUp 1s 1;
width: 570px;
margin: 0 auto; }
.info .field input {
width: 400px;
margin: 10px 0px; }
.info .field .btn {
margin: 10px 0px; }
.info .field .green-btn {
width: initial; }
.info .social {
margin: 0px 0px 60px 0px; }
.about {
background: url("http://printgram.noflagra.com/wp-content/themes/Printgram/css/images/comofunciona-bg.png") repeat scroll 0 0 transparent; }
.about .logo {
color: white;
font-size: 50px; }
.about p {
font-weight: bold; }
.about h2 {
font-size: 22px; }
.about .left {
float: left;
width: 50%;
margin-top: 50px;
text-align: center; }
.about .right {
width: 50%;
float: right;
color: white;
font-weight: 300; }
.demo .content {
padding: 130px 0px 150px 0px;
text-align: center; }
.demo h2 {
font-size: 30px; }
.demo .social {
margin-top: 20px;
display: inline-block; }
.demo .social .fb, .demo .social .gp, .demo .social .tw {
float: left;
margin: 0 5px; }
.features {
background: url("http://printgram.noflagra.com/wp-content/themes/Printgram/css/images/porque-bg.png") repeat scroll 0 0 transparent;
overflow: hidden; }
.features .content {
padding: 100px 0px;
margin: 0 auto; }
.features .block {
float: left;
width: 30%;
margin: 15px;
text-align: center;
position: relative; }
.features .block h3 {
font-size: 22px; }
.features .block p {
padding: 0px 20px; }
.features .feature1, .features .feature2, .features .feature3, .features .feature4, .features .feature5, .features .feature6 {
width: 152px;
height: 153px;
margin: auto; }
.features .feature1 {
background: url("http://printgram.noflagra.com/wp-content/uploads/2012/08/2-tralha1.png") no-repeat scroll center center transparent;
}
.features .feature2 {
background: url("http://printgram.noflagra.com/wp-content/uploads/2012/08/1-instagram1.png") no-repeat scroll center center transparent;
}
.features .feature3 {
background: url("http://printgram.noflagra.com/wp-content/uploads/2012/08/3-foto1.png") no-repeat scroll center center transparent;
}
footer {
background: url("http://printgram.noflagra.com/wp-content/themes/Printgram/css/images/footer-bg.png") repeat scroll 0 0 transparent;
border-top: 10px solid #464646;
color: white;
height: 100%;
}
footer .content {
width: 600px;
padding: 40px 0px;
text-align: center; }
footer .content .logo {
font-size: 25px;
font-weight: 300; }
footer .content p, footer .content a {
font-weight: 700; }
footer .content ul {
text-align: center;
padding: 0px;
display: block;
margin-bottom: 50px; }
footer .content ul li {
display: inline-block; }
footer .content ul a {
border-radius: 3px;
-webkit-border-radius: 3px;
-o-border-radius: 3px;
-moz-border-radius: 3px;
background: #0cad6c;
padding: 3px 7px;
margin: 3px; }
#media only screen and (max-width: 480px) {
header .content {
padding: 0;
margin-top: 0;
margin-bottom: 0; }
#bgMax {
left: 50%;
margin-left: -200px; }
#wrapper {
width: inherit; }
.content, .info {
margin: 20% auto;
width: 85%;
overflow: hidden; }
.info {
margin: 12% auto;
padding-top: 50px;
padding-bottom: 50px; }
.info .logo {
font-size: 55px; }
.info h2 {
font-size: 20px; }
.info small {
font-size: 11px; }
.info .field {
width: 100%; }
.info .field input, .info .field .green-btn {
padding: 12px;
font-size: 12px;
margin-top: 0px;
margin-bottom: 5px; }
.info .field input {
width: 90%%; }
.about {
font-size: 12px;
text-align: center; }
.about .left, .about .right {
width: auto; }
.about .left {
float: inherit;
margin: 0; }
.about .left h2 {
font-size: 40px; }
.about .right h2 {
font-size: 18px; }
.about .right p {
font-size: 14px;
line-height: 28px; }
.demo .content {
padding: 50px 0px; }
.demo .social {
width: 100px; }
.features {
font-size: 12px; }
.features .content {
width: 80%;
padding: 50px 0px; }
.features .block {
width: auto;
float: inherit;
margin: 55px 0px; }
.features .block h3 {
font-size: 18px; }
.features .block p {
line-height: 28px;
font-size: 14px; }
footer .content {
margin: 20% auto;
width: 85%;
overflow: hidden;
margin: 5% auto; } }
#media only screen and (min-width: 481px) and (max-width: 1024px) {
header .content {
padding: 0;
margin-top: 0;
margin-bottom: 0; }
#wrapper {
width: inherit; }
.content, .info {
margin: 15% auto;
width: 70%;
overflow: hidden; }
.info {
margin: 8% auto;
padding-top: 50px;
padding-bottom: 50px; }
.info .field {
width: 420px; }
.info .field input {
width: 50%; }
.about {
text-align: center; }
.about .left, .about .right {
width: auto; }
.about .left {
float: inherit;
margin: 0; }
.demo .content {
padding: 50px 0px; }
.features .content {
width: 80%;
padding: 50px 0px; }
.features .block {
width: auto;
float: inherit;
margin: 55px 0px; }
footer .content {
margin: 15% auto;
width: 70%;
overflow: hidden;
margin: 5% auto; } }
.error {
color: white;
text-shadow: 0px 1px 1px #353535;
-webkit-text-shadow: 0px 1px 1px #353535;
-o-text-shadow: 0px 1px 1px #353535;
-moz-text-shadow: 0px 1px 1px #353535;
animation: fadeInUp 1s 1;
-moz-animation: fadeInUp 1s 1;
-webkit-animation: fadeInUp 1s 1;
-o-animation: fadeInUp 1s 1;
font-weight: bold; }
.exist, .succesfull {
color: #5f5f5f;
font-size: 16px;
font-weight: normal;
width: 270px;
padding: 12px 10px;
margin: 0 auto;
border-radius: 5px;
background: white;
animation: fadeInUp 1s 1;
-moz-animation: fadeInUp 1s 1;
-webkit-animation: fadeInUp 1s 1;
-o-animation: fadeInUp 1s 1; }
.temp {
display: none;
color: #cccccc; }

Resources