I've created This toggle button, and i can't set it's size to percentage - so it could be responsive. i was manage to set it's text to viewport width and height - and it's working well, but i don't want the button in viewport measurements....
perhaps ::before and ::after cannot receive measurements in percentage?
Html:
<div class="cont">
<div class="box">
<div class="material-switch">
<input id="someSwitchOptionDefault" name="someSwitchOption001"
type="checkbox" />
<label for="someSwitchOptionDefault" class="label-default"><span
class="homme">Homme</span><span class="femme">Femme</span>
</label>
</div>
</div>
</div>
Css:
.cont {
padding: 50px;
background-color: #e9e9e9;
width: 100vw;
height: 100vh;
}
.box {
width: 100px;
height: 100px;
}
.material-switch > input[type="checkbox"] {
display: none;
}
.material-switch > label {
cursor: pointer;
height: 0px;
position: relative;
width: 40px;
}
.material-switch > input[type="checkbox"] + label::before {
content: "\f222";
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #333333;
text-align: right;
border: 1px solid #dcdcdc;
padding-left: 10px;
padding-right: 10px;
}
.material-switch > label::before {
background-color: #f6f6f6;
border-radius: 16px;
height: 24px;
margin-top: -12px;
position: absolute;
width: 100px;
}
.material-switch > label::after {
/*--button---*/
content: "";
font-size: 18px;
background-color: #fff;
border-radius: 15px;
height: 24px;
left: -4px;
margin-top: -8px;
position: absolute;
top: -4px;
width: 73px;
border: 1px solid #dcdcdc;
}
.material-switch > input[type="checkbox"]:checked + label::before {
background-color: #f6f6f6;
content: "\f221";
color: "blue";
font-family: FontAwesome;
text-align: left;
}
.material-switch > input[type="checkbox"]:checked + label::after {
background-color: #fff;
left: 30px;
}
.femme {
display: none;
}
.material-switch > input[type="checkbox"]:checked + label>span.homme {
display: none;
}
.material-switch > input[type="checkbox"]:checked + label>span.femme {
display: block;
}
.homme {
font-family: 'Roboto Light', sans-serif;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #5d5d5d;
font-size: 1vw;
position: absolute;
top: -8px;
left: 9px;
z-index: 999;
}
.femme {
font-family: 'Roboto Light', sans-serif;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #5d5d5d;
font-size: 1vw;
position: absolute;
top: -8px;
z-index: 999;
}
.material-switch > input[type="checkbox"]:checked + label .femme {
left: 41px;
}
.homme::before {
content: "\f222";
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #49c8c1;
margin-right: 5px;
}
.femme::before {
content: "\f221";
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
color: #49c8c1;
margin-right: 5px;
}
I see that in the css you have overridden lot of html DOM properties, like for <input> component. I would suggest you to use simple and elegant toggle buttons available with normal css.
You can check below toggle button examples:
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_switch
https://codepen.io/mburnette/pen/LxNxNg
Related
How to put/place function click hide in popup button without js only through Html and CSS?
I need the close button to close the popup as the x button closes the button.
is there a way to implement this in the HTML or CSS code?
at the bottom is an example of the code.
<!doctype html>
<head>
</head>
<body>
<div id="css-modal">
<input id="modal" class="css-modal-check" type="checkbox" checked />
<div class="css-modal">
<label for="modal" class="close"></label>
<p><img src="./popup-logo.png" alt="" class="center"></p>
<h2>DISCLAIMER</h2>
<p>This site is for recreational use only!
</p>
<div class="css-modal-btn2"><button class="btn2 btn2-primary btn-md">CLOSE</button></a></div>
</div>
<div id="overlay"></div>
</div>
</div>
</body>
</html>
On the bottom, is the css code as a sample.
/* Main Styles */
body {
background-color: #f5f5f5;
color: #333;
font-family: "Arial", Arial, sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 1.75;
opacity: 15;
}
#page-wrapper {
padding: 1.5em;
}
p.center {
text-align: center;
color: #fff;
}
h1 {
color: #fff;
text-align: center;
text-transform: uppercase;
font-weight: 400;
}
/* Modal Styles */
#css-modal {
bottom: 0;
height: 100%;
left: 0;
pointer-events: none;
position: fixed;
right: 0;
text-align: center;
top: 0;
white-space: nowrap;
padding: 1.5rem 1.6em!important;
z-index: 99;
}
#css-modal h2 {
color: #fff;
font-weight: 700;
font-size: 2em;
letter-spacing: 0.02em;
padding: 0;
margin-bottom: 0.5em;
margin-top: 0;
}
#css-modal .css-modal-check {
display: none;
pointer-events: auto;
}
#css-modal .css-modal-check:checked ~ .css-modal {
opacity: 1;
pointer-events: auto;
}
#css-modal .css-modal {
background: #B92101;
border-radius: 3px;
display: inline-block;
width:600px;
max-width:100%;
min-height:300px;
opacity: 0;
padding: 2.7em;
pointer-events: none;
position: relative;
text-align: center;
vertical-align: middle;
white-space: normal;
z-index: 1;
}
#css-modal .css-modal p {
text-align: center;
color: #fff;
}
#css-modal .css-modal .close {
color: #cca72f;
position: absolute;
right: 1em;
top: 0.5em;
}
#css-modal .css-modal .css-modal-btn2 button {
font-weight: 700;
letter-spacing: 0.05em;
margin-top: 1em;
}
#css-modal .css-modal-check:checked ~ #overlay {
opacity: 0.8;
pointer-events: auto;
}
#css-modal #overlay {
background: #000;
bottom: 0;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transition: opacity 0.8s;
}
#css-modal:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
.close:after {
color: #cca72f;
content: "\0058";
float: right;
font-size: 1.75em;
}
#css-modal .btn2-primary {
color: #fff;
background-color: #cca72f;
}
#css-modal .btn2-primary:hover {
background-color: #b39124;
}
#css-modal .btn2 {
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
padding: 0.75em 1.25em;
text-align: center;
}
working with the code snipped you provided, I changed a few things to demonstrate how to accomplish this without js. Essentially you use the checkbox to manage state, and change the css display value depending on whether or not the checkbox is checked. You can use the label to trigger the checkbox. I also hid the checkbo itself so that it's not visible and the state is managed in the background. Hopefully this helps!
<head>
<style>
label > button {
pointer-events: none;
user-select: none;
}
.css-modal {
display: none;
}
#modal {
display: none;
}
#modal:checked ~ .css-modal {
display: block;
}
</style>
</head>
<body>
<div id="css-modal">
<input id="modal" class="css-modal-check" type="checkbox" checked />
<div class="css-modal">
<p><img src="./popup-logo.png" alt="" class="center" /></p>
<h2>DISCLAIMER</h2>
<p>This site is for recreational use only!</p>
<div class="css-modal-btn2">
<label for="modal" class="close">
<button class="btn2 btn2-primary btn-md">CLOSE</button>
</label>
</div>
</div>
<div id="overlay"></div>
</div>
</body>
/* Main Styles */
body {
background-color: #f5f5f5;
color: #333;
font-family: "Arial", Arial, sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 1.75;
opacity: 15;
}
#page-wrapper {
padding: 1.5em;
}
p.center {
text-align: center;
color: #fff;
}
h1 {
color: #fff;
text-align: center;
text-transform: uppercase;
font-weight: 400;
}
/* Modal Styles */
#css-modal {
bottom: 0;
height: 100%;
left: 0;
pointer-events: none;
position: fixed;
right: 0;
text-align: center;
top: 0;
white-space: nowrap;
padding: 1.5rem 1.6em!important;
z-index: 99;
}
#css-modal h2 {
color: #fff;
font-weight: 700;
font-size: 2em;
letter-spacing: 0.02em;
padding: 0;
margin-bottom: 0.5em;
margin-top: 0;
}
#css-modal .css-modal-check {
display: none;
pointer-events: auto;
}
#css-modal .css-modal-check:checked ~ .css-modal {
opacity: 1;
pointer-events: auto;
}
#css-modal .css-modal {
background: #B92101;
border-radius: 3px;
display: inline-block;
width:600px;
max-width:100%;
min-height:300px;
opacity: 0;
padding: 2.7em;
pointer-events: none;
position: relative;
text-align: center;
vertical-align: middle;
white-space: normal;
z-index: 1;
}
#css-modal .css-modal p {
text-align: center;
color: #fff;
}
#css-modal .css-modal .close {
color: #cca72f;
position: absolute;
right: 1em;
top: 0.5em;
}
#css-modal .css-modal .css-modal-btn2 button {
font-weight: 700;
letter-spacing: 0.05em;
margin-top: 1em;
user-select: none;
pointer-events: none;
}
#css-modal .css-modal-check:checked ~ #overlay {
opacity: 0.8;
pointer-events: auto;
}
#css-modal #overlay {
background: #000;
bottom: 0;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
transition: opacity 0.8s;
}
#css-modal:before {
content: "";
display: inline-block;
height: 100%;
vertical-align: middle;
}
.close:after {
color: #cca72f;
content: "\0058";
float: right;
font-size: 1.75em;
}
#css-modal .btn2-primary {
color: #fff;
background-color: #cca72f;
}
#css-modal .btn2-primary:hover {
background-color: #b39124;
}
#css-modal .btn2 {
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
padding: 0.75em 1.25em;
text-align: center;
}
<!doctype html>
<head>
</head>
<body>
<div id="css-modal">
<input id="modal" class="css-modal-check" type="checkbox" checked />
<div class="css-modal">
<p><img src="./popup-logo.png" alt="" class="center"></p>
<h2>DISCLAIMER</h2>
<p>This site is for recreational use only!
</p>
<div class="css-modal-btn2">
<label for="modal" class="close"></label>
<label for="modal"><div class="css-modal-btn2"><button class="btn2 btn2-primary btn-md">Close</button></label></div>
</div>
</div>
<div id="overlay"></div>
</div>
</body>
</html>
I am wanting titles underlined with the :after method. I am getting it to work partially. What I cannot figure out is how to get the underline ("after) to only be under the span text inside of the .slantTitleWrap.
Does anyone see what I am doing wrong?
.slantBlock2Title {
color: #4D4D4D;
font-size: 1.5rem;
font-family: 'Muli', sans-serif;
line-height: 1.5em;
}
.slantTitleWrap span:after {
content: '';
display: block;
width: 40%;
margin-top: 5px;
background: #b82222;
height: 2px;
}
<div class="slantTitleWrap">
<span class="slantBlock2Title">Uderline me</span>
</div>
You can achieve this by using 'display: inline-block'.
.slantBlock2Title {
color: #4D4D4D;
font-size: 1.5rem;
font-family: 'Muli', sans-serif;
line-height: 1.5em;
display: inline-block;
}
.slantTitleWrap span:after {
content: '';
display: block;
width: 100%;
margin-top: 5px;
background: #b82222;
height: 2px;
}
<div class="slantTitleWrap">
<span class="slantBlock2Title">Uderline me</span>
</div>
I only added the positions to make it work like you wanted:
.slantBlock2Title {
position: relative; /* Added */
color: #4D4D4D;
font-size: 1.5rem;
font-family: 'Muli', sans-serif;
line-height: 1.5em;
}
.slantTitleWrap span:after {
position: absolute; /* Added */
content: '';
display: block;
width: 100%; /* Modified */
margin-top: 5px;
background: #b82222;
height: 2px;
}
p{
font-family: 'Muli', sans-serif;
}
<div class="slantTitleWrap">
<span class="slantBlock2Title">U<u>n</u>derline me</span>
</div>
<br>
<p>(I added the ānā, too! :D)</p>
Hope it helps!
How would I go about adding a sticky footer to the bottom of my page that isn't fixed. I made the mistake of adding the footer to my website last. The footer would be on top of an absolute positioned image. I tried using the absolute position, min-height solution but it didn't work. The footer isn't at the bottom of the total page (it will be at the bottom of the page of the initial starting position). Here is the HTML code and CSS code. I'm not sure where the issue/conflict and I have tried scanning and looking in the code but can't see it. HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Home </title>
<meta name="description" content="A music review website">
<link rel="stylesheet" href="css/main.css">
</head>
<body class="homepage">
<header>
<a href="index.php">
<img class="banner"
src="Pictures/second_banner_image_blue.jpg">
</a>
</header>
<nav>
<a class="homelink" id="activehome" href="index.php">Home</a>
<a class="reviewasonglink" href="Review_a_song.php">Review a
song</a>
<a class="reviewslink" href="Sort_by_rating.php">Reviews</a>
<a class="faqlink" href="faq.php">FAQ</a>
<a class="contactlink" href="contactpage.php">Contact us</a>
<form method="get" action="search.php">
<input type="text" name="q" class="searchbox"
placeholder="Search for a song, album or artist here...">
<input type="image" name="Search"
src="Pictures/magnifyingglass.png" class="searchbutton">
</form>
</nav>
<a href="Review_a_song.php"><img class="homepic1"
src="Pictures/concert_edit.jpg"></a>
<a href="Review_a_song.php"><p class="hometitle1">Review your
favourite music</p></a>
<a href="sort_by_rating.php"><img class="homepic2"
src="Pictures/songreviews_edit.jpg"></a>
<a href="sort_by_rating.php"><p class="hometitle2">Read
comprehensive reviews</p></a>
<a href="faq.php"><img class="homepic3"
src="Pictures/questions_edit.jpg"></a>
<p class="hometitle3">Questions?</p>
<footer>
<p>Copyright</p>
</footer>
</body>
</html>
CSS:
#font-face {
font-family: opensans; src: url('fonts/OpenSans.tff');
font-family: roboto; src: url('fonts/Roboto.tff');
font-family: robotobold; src: url('fonts/RobotoBold.tff');
font-family: headings; src: url('fonts/adamcg.otf');
}
html {
position: relative;
min-height: 100%;
}
body {
margin:0px;
padding: 0px;
height: 100%;
overflow-x: hidden;
background-attachment: fixed;
}
.homepage {
background-attachment: scroll;
}
.homepic1 {
height: 100%;
width: 100%;
position: absolute;
cursor: pointer;
}
.homepic2 {
height: 80%;
width: 100%;
position: absolute;
cursor: pointer;
transform: translateY(500px);
}
.homepic3 {
height: 100%;
width: 100%;
position: absolute;
cursor: pointer;
transform: translateY(972px);
}
header {
height: 86px;
}
a {
text-decoration-line: none;
}
.background {
display: block;
height: 100%;
}
a:visited {
color: currentColor;
}
h1 {
margin-left: 53px;
margin-top: 80px;
color: white;
font-family: opensans, sans-serif;
}
h2 {
margin-left: 46px;
text-decoration-line: underline;
color: white;
position: absolute;
transform: translateY(428px);
font-family: opensans, sans-serif;
}
h4 {
font-size: 30px;
font-family: opensans, sans-serif;
}
.review_content{
margin-left: 53px;
transform: translateY(50px);
color: white;
font-family: opensans, sans-serif;
}
nav {
width: 100%;
height: 40px;
background-color:white;
border: 0.5px solid black;
z-index: 1;
position: fixed;
}
nav a{
width:11.4%;
float: left;
text-align: center;
height: 30px;
padding-top: 10px;
color: black;
}
.homelink {
margin-left: 0px;
}
.hometitle1 {
color: black;
margin-top: 90px;
font-size: 65px;
position: absolute;
font-family: headings, sans-serif;
margin-left: 200px;
font-weight: 600;
text-shadow: 2px 2px 6px #565656;
cursor: pointer;
}
.hometitle2 {
color: black;
margin-top: 0px;
font-size: 65px;
position: absolute;
font-family: headings, sans-serif;
color: #16308d;
margin-left: 190px;
font-weight: 600;
text-shadow: 3px 3px 6px #0f2163;
transform: translateY(600px);
cursor: pointer;
}
.hometitle3 {
color: black;
margin-top: 0px;
font-size: 65px;
position: absolute;
font-family: headings, sans-serif;
color: #510000;
margin-left: 440px;
font-weight: 600;
text-shadow: 2px 2px 6px #450000;
transform: translateY(1070px);
cursor: pointer;
}
.reviewasonglink, .reviewslink, .contactlink, .faqlink, .homelink {
transition: 0.4s;
font-size: 16px;
text-decoration: none;
font-family: opensans, sans-serif;
}
.reviewasonglink:hover, .reviewslink:hover, .contactlink:hover,
.faqlink:hover, .homelink:hover {
background-color: #404040;
color:#e6e6e6;
}
#activesortbyrating, #activereviewasong, #activecontact, #activefaq,
#activehome {
background-color: #5e5e5e;
color:#e6e6e6;
}
#activesortbyrating:hover, #activereviewasong:hover, #activecontact:hover,
#activefaq:hover, #activehome:hover {
background-color: #404040;
color:#e6e6e6;
}
.banner {
z-index: 1;
position: fixed;
}
.searchbox {
float: right;
width: 230px;
margin-right: 80px;
padding: 5px;
height: 29px;
}
input::placeholder {
color: black;
font-size: 12.8px;
font-family: opensans, sans-serif;
}
input[name="q"] {
font-family: opensans, sans-serif;
border: none;
padding-bottom: 0px;
border-bottom: 0.8px solid black;
}
textarea:focus, input:focus{
outline: none;
}
.formentries {
margin-top: 80px;
margin-left: 53px;
color: white;
font-family: opensans, sans-serif;
}
.warning {
font-weight: bold;
}
.formentry {
font-size: 20px;
font-weight: bold;
font-family: opensans, sans-serif;
}
.searchbutton {
float: right;
width: 35px;
height: 35px;
transform: translateX(273px);
font-family: opensans, sans-serif;
}
input[type="radio"] {
position: absolute;
font-family: opensans, sans-serif;
}
textarea {
border: 1px solid black;
border-radius: 5px;
background-color: lightgray;
font-family: opensans, sans-serif;
}
select {
background-color: lightgray;
}
.formbox {
font-size: 20px;
font-family: opensans, sans-serif;
border: 1px solid black;
background-color: lightgray;
border-radius: 5px;
font-family: opensans, sans-serif;
}
.contactform {
padding-left: 53px;
margin-top: 25px;
font-size: 19px;
font-weight: 600;
color: white;
font-family: opensans, sans-serif;
}
.contactinfo {
padding-left: 53px;
margin-top: 70px;
color: white;
font-family: roboto, sans-serif;
}
.contactentry {
font-size: 18px;
font-family: opensans, sans-serif;
border: 1px solid black;
background-color: lightgray;
border-radius: 5px;
font-family: opensans, sans-serif;
}
.contactmessage {
font-size:15px;
font-family: opensans, sans-serif;
}
.searchtitle, .searchartist, .searchalbum {
color: white;
transform: translateX(53px);
font-family: opensans, sans-serif;
}
.searchtitle {
font-weight: bolder;
font-size: 18px;
text-decoration-line: none;
padding-top: 20px;
}
.FAQ {
margin-left: 53px;
margin-top: 80px;
margin-right: 30px;
color: white;
font-family: opensans, sans-serif;
}
.genreoptions {
max-width: 960px;
margin-left: 45px;
margin-top: 70px;
position: absolute;
border-spacing: 1;
}
.ratingoptions {
max-width: 960px;
transform: translateX(45px);
margin-top: 277px;
position: absolute;
border-spacing: 1;
}
.reviews th {
font-weight: 400;
background: #024457;
color:white;
}
.reviews {
max-width: 960px;
margin-left: 44px;
margin-top: 520px;
position: absolute;
margin-bottom: 10px;
}
.genreoptions thead th {
font-weight: 400;
background: #8a97a0;
color: #FFF;
}
.ratingoptions thead th {
font-weight: 400;
background: #8a97a0;
color: #FFF;
}
.ratingoptions tr {
background: #f4f7f8;
border-bottom: 1px solid #FFF;
margin-bottom: 5px;
}
.genreoptions tr {
background: #f4f7f8;
border-bottom: 1px solid #FFF;
margin-bottom: 5px;
}
.reviews tr {
background:white;
border-bottom: 1px solid #FFF;
margin-bottom: 5px;
}
.ratingoptions tr:nth-child(even) {
background: #e8eeef;
}
.genreoptions tr:nth-child(even) {
background: #e8eeef;
}
.reviews tr:nth-child(even) {
background:#e0ebfc;
}
th, td, tr {
padding: 8px;
font-weight: 300;
font-family: opensans, sans-serif;
}
.circle {
width: 17px;
height: 17px;
float: right;
padding-left: 25px;
}
input[type=radio]{
visibility: hidden;
position: absolute;
}
label > input + img{
cursor:pointer;
filter: brightness(0%);
transition: all 0.5s ease;
}
label > input:checked + img {
filter: brightness(100%);
}
label {
cursor: pointer;
display: block;
font-family: opensans, sans-serif;
}
.genreoptions, .ratingoptions td {
width: 33%;
}
.reviews tbody tr:hover td {
background-color:#d4d5d6;
}
.genreoptions tbody td:hover {
background-color: lightgray;
}
.ratingoptions tbody td:hover {
background-color: lightgray;
}
.reviews th, td {
cursor: pointer;
text-align: left;
}
.sortinfo {
position: absolute;
color: white;
transform: translate(45px, 468px);
font-family: opensans, sans-serif;
}
.filterbutton {
position: absolute;
transform: translate(45px, 405px);
width: 180px;
height: 30px;
border-radius: 20px;
background-color:white;
border: 0.5px solid midnightblue;
cursor: pointer;
font-family: opensans, sans-serif;
}
.body {
margin-top: 5px;
margin-left: 8px;
font-family: opensans, sans-serif;
}
.noreviewsinfo {
position: absolute;
transform: translate(45px, 420px);
color: white;
font-size: 30px;
font-family: opensans, sans-serif;
}
.submitbutton {
height: 30px;
width: 80px;
font-size: 16px;
margin-top: 8px;
margin-bottom: 8px;
background-color:steelblue;
color: black;
border: 0.5px solid black;
border-radius: 5px;
cursor: pointer;
box-shadow: inset 0 0 0 1px #27496d;
font-family: opensans, sans-serif;
}
.submitbutton:hover {
filter: brightness(70%);
font-family: opensans, sans-serif;
}
.nosearchresults {
color: white;
margin-left: 53px;
margin-top: 5px;
font-size: 17px;
font-family: opensans, sans-serif;
}
footer {
height: 30px;
width: 100%;
background-color: gray;
border: 1px solid black;
}
I'm creating icons using only CSS3. So far so good, but I've run into a problem with the simplest one.
I just want to have an "!" centered in a circle, but its position isn't consistent. Sometimes it's a pixel higher, a pixel to the left, or both.
I have no idea what's causing this.
Here's a fiddle.
.nos {
position: relative;
height: 12px; width: 12px;
border: 2px solid #e04006;
border-radius: 50%; -webkit-border-radius: 50%; -moz-border-radius: 50%;
display: block;
color: #e04006;
overflow: hidden;
cursor: default;
}
.nos:hover {
overflow: visible;
}
.nos span {
position: absolute;
padding-left: 18px;
display: block;
font-size: 14px; line-height: 16px; text-decoration: underline;
white-space: nowrap;
}
.nos:before {
content: '\21';
position: absolute; top: 0; bottom: 0; left: 0; right: 0;
margin: 0;
height: 16px; width: 16px;
display: block;
font-family: "Lucida Console", Monaco, monospace; text-align: center; font-size: 12px; line-height: 12px; font-weight: bold;
}
Remove the height: 16px; width: 16px; from .nos:before
Update Fiddle
Looks like I managed to fix it after some tinkering. Not sure what did the trick.
.nos {
position: relative;
width: 12px; height: 12px;
border: 2px solid #e04006;
-webkit-border-radius: 50%; -moz-border-radius: 50%; border-radius: 50%;
display: inline-block;
color: #e04006;
overflow: hidden;
cursor: default;
}
.nos:hover {
overflow: visible;
}
.nos span {
position: absolute; top: -2px; left: -2px;
height: 16px;
padding-left: 18px;
display: block;
text-decoration: underline; font-size: 14px; line-height: 16px;
white-space: nowrap;
}
.nos:before {
content: '\21';
position: absolute; top: -2px; left: -2px;
width: 16px;
display: block;
font-family: Verdana, Geneva, sans-serif; text-align: center; font-weight: bold; font-size: 13px; line-height: 13px;
}
Fiddle
I can't make my background only in my text..allways go futher until the end of the screen.
Any idea what i'm doing wrong?
Here's my HTML:
<div class="textSlide">
<span id="firstTitle">We help you find everyone you</span>
<span id="secondTitle">need to get you started.</span>
<span id="thirdTitle">Look Ouch is an online meeting point where all kinds</span>
<span id="fourthTitle">of artists can unite to make ideas happen.</span>
</div>
Here's my CSS:
.textSlide span { z-index: 999; position: relative; margin-left: 10%; font-family: Montserrat; display: block; padding: 5px; }
.textSlide #firstTitle { margin-top: 120px; font-size: 34px; font-weight: bold; background-color: #7d37e6; color: #fff; }
.textSlide #secondTitle { font-size: 34px; font-weight: bold; margin-top: 5px; background-color: #7d37e6; color: #fff; }
.textSlide #thirdTitle { font-size: 18px; margin-top: 12px; background-color: #7933e1; color: #fff; }
.textSlide #fourthTitle { font-size: 18px; margin-top: 5px; background-color: #7933e1; color: #fff; }
FIDDLE
Change the display: block, to display: inline-block;
http://jsfiddle.net/w456u/1/
.textSlide span { z-index: 999; position: relative; margin-left: 10%; font-family: Montserrat; display: inline-block; padding: 5px; }
.textSlide #firstTitle { margin-top: 120px; font-size: 34px; font-weight: bold; background-color: #7d37e6; color: #fff; }
.textSlide #secondTitle { font-size: 34px; font-weight: bold; margin-top: 5px; background-color: #7d37e6; color: #fff; }
.textSlide #thirdTitle { font-size: 18px; margin-top: 12px; background-color: #7933e1; color: #fff; }
.textSlide #fourthTitle { font-size: 18px; margin-top: 5px; background-color: #7933e1; color: #fff; }