How to align <label> on the same line with other element - css

How can I get <label> and #slider to be on the same line?
header {
background: #2f2f2f;
width: 600px;
height: 28px;
margin: 0 auto;
padding: 0 10px;
color: #FFF;
font-size: 12px;
}
header a {
color: #FFF;
}
header a:hover,
header a:focus {
color: #DDD;
}
header #title {
padding: 7px 0;
float: left;
}
header #onoff {
padding: 6px 0;
float: right;
height: 16px;
}
header #onoff label#switch input {
display: none;
}
header #onoff label#switch input+#slider {
background: #CCC;
display: inline-block;
width: 27px;
height: 16px;
position: relative;
cursor: pointer;
transition: .4s;
border-radius: 34px;
}
header #onoff label#switch input+#slider:before {
content: "";
background: #FFF;
width: 16px;
height: 16px;
position: absolute;
transition: .4s;
border-radius: 50%;
}
header #onoff label#switch input:checked+#slider {
background: #4CD964;
}
header #onoff label#switch input:checked+#slider:before {
transform: translateX(11px);
}
<header>
<a id="title" href=".">Site title</a>
<span id="onoff"><label id="switch">NIGHT MODE<input id="toggle" type="checkbox"><span id="slider"></span></label>
</span>
</header>

I strongly discourage you to use floats for this. Use a flexbox instead:
header {
background: #2f2f2f;
width: 600px;
height: 28px;
margin: 0 auto;
padding: 0 10px;
color: #FFF;
font-size: 12px;
display: flex;
justify-content: space-between;
}
header a {
color: #FFF;
}
header a:hover,
header a:focus {
color: #DDD;
}
header #title {
padding: 7px 0;
}
header #onoff {
padding: 6px 0;
height: 16px;
}
header #onoff label#switch input {
display: none;
}
header #onoff label#switch input+#slider {
background: #CCC;
display: inline-block;
width: 27px;
height: 16px;
position: relative;
cursor: pointer;
transition: .4s;
border-radius: 34px;
}
header #onoff label#switch input+#slider:before {
content: "";
background: #FFF;
width: 16px;
height: 16px;
position: absolute;
transition: .4s;
border-radius: 50%;
}
header #onoff label#switch input:checked+#slider {
background: #4CD964;
}
header #onoff label#switch input:checked+#slider:before {
transform: translateX(11px);
}
#switch {
display: flex;
align-items: center;
}
<header>
<a id="title" href=".">Site title</a>
<span id="onoff"><label id="switch">NIGHT MODE<input id="toggle" type="checkbox"><span id="slider"></span></label>
</span>
</header>

I think that's what you want.
header {
background: #2f2f2f;
width: 600px;
height: 28px;
margin: 0 auto;
padding: 0 10px;
color: #FFF;
font-size: 12px;
}
header a {
color: #FFF;
}
header a:hover,
header a:focus {
color: #DDD;
}
header #title {
padding: 7px 0;
float: left;
}
header #onoff {
padding: 6px 0;
float: right;
height: 16px;
}
header #onoff label#switch input {
display: none;
}
header #onoff label#switch input+#slider {
background: #CCC;
/* display: inline-block; */
width: 27px;
height: 16px;
position: relative;
cursor: pointer;
transition: .4s;
border-radius: 34px;
}
header #onoff label#switch input+#slider:before {
content: "";
background: #FFF;
width: 16px;
height: 16px;
position: absolute;
transition: .4s;
border-radius: 50%;
}
header #onoff label#switch input:checked+#slider {
background: #4CD964;
}
header #onoff label#switch input:checked+#slider:before {
transform: translateX(11px);
}
#switch {
display: flex;
width: 120px;
flex-direction: row;
justify-content: space-around;
line-height: 16px;
}
<header>
<a id="title" href=".">Site title</a>
<span id="onoff">
<label id="switch">NIGHT MODE<input id="toggle" type="checkbox">
<span id="slider"></span>
</label>
</span>
</header>

Related

How to make Search bar slide from right to left

This search bar now expands from left to right while hover or click. How to modify it, so it expands from right to left. CSS Only, no JS. I want to place this on the right side of the page.
Please help in modifing this code so it expands from the right to left.
Now, when the bar is sticky to the right side, it shakes a bit while expanding. Changing expand direction will remove shake effect.
.search-sticky {
position: sticky;
top: 30px;
left: 100%;
z-index: 55;
border-radius: 50px;
background-color: red;
padding: 2.5rem;
}
.search-icon {
position: relative;
width: 24px;
height: 24px;
flex-shrink: 0;
top: 3px
}
.search-input {
outline: none;
border: none;
background: none;
width: 0;
padding: 0;
color: white;
float: left;
transition: .3s;
line-height: 1.5;
font-size: 6rem;
position: relative;
left: 1rem;
}
.search-btn {
float: right;
width: 40px;
height: 40px;
border-radius: 50px;
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
transition: .3s;
}
.search-input:focus,
.search-input:not(:placeholder-shown) {
width: 200px;
}
.search-box:hover>.search-input {
width: 200px;
}
.search-box:hover>.search-btn,
.search-input:focus+.search-btn,
.search-input:not(:placeholder-shown)+.search-btn {
background: grey;
}
.search-sticky:hover,
.search-sticky:focus-within {
background-color: grey;
}
.search-sticky button {
padding: 0;
background: none;
border: none;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
}
<div class="search-sticky">
<form class="search-box">
<input type="text" name="q" id="search-query" class="search-input" placeholder="Search ....">
<a class="search-btn" href="#">
<button type="submit" class="search-button"><img class="search-icon" alt="Search" src="/icons/search.svg" /></button>
</a>
</form>
</div>
Updated
I hope this helps
.search-sticky {
position: sticky;
top: 30px;
left: 100%;
z-index: 55;
border-radius: 50px;
background-color: whitesmoke;
padding: 0.5rem 2.5rem;
}
.search-box{
display: flex;
justify-content: space-between;
align-items: center;
}
.search-icon {
position: relative;
width: 40px;
height: 40px;
margin-left: auto;
}
.search-input {
outline: none;
border: none;
background: none;
width: 0;
padding: 0;
color: white;
transition: .3s;
line-height: 1.5;
font-size: 4rem;
position: relative;
display: inline-block;
}
.search-btn {
width: 40px;
height: 40px;
border-radius: var(--br-md);
display: inline-block;
justify-content: center;
align-items: center;
text-decoration: none;
transition: .3s;
}
.search-input:focus,
.search-input:not(:placeholder-shown) {
width: calc(100% - 60px);
}
.search-box:hover>.search-input {
width: calc(100% - 60px);
}
/*.search-box:hover>.search-btn,
.search-input:focus+.search-btn,
.search-input:not(:placeholder-shown)+.search-btn {
background: grey;
}
// not needed */
.search-sticky:hover,
.search-sticky:focus-within {
background-color: lightgray;
}
.search-sticky button {
padding: 0;
background: none;
border: none;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
}
<div class="search-sticky">
<form class="search-box">
<input type="text" name="q" id="search-query" class="search-input" placeholder="Search ....">
<a class="search-btn" href="#">
<button type="submit" class="search-button"><img class="search-icon" alt="Search" src="https://img.icons8.com/ios-filled/2x/search.png" /></button>
</a>
</form>
</div>

Text input - can't align text top or bottom, only center

folks! I'm trying to align the text inside a text form input to be next to the line at the bottom, but it doesn't quite concede, insisting on being center aligned.
I've put some vertical-align: bottom on different elements, but it didn't work (it's on the code below).
Here is the codepen: https://codepen.io/ironsand-sou-eu/pen/zYEmEdw
HTML:
<div class="form-input field">
<input type="text" name="my_input" id="my_input" value="I'd love to be a little closer to the line below! Can you help me?">
<label for="my_input" data-title="Just some label"></label>
</div>
CSS:
.form-input {
width: 100%;
background-color: transparent;
border-bottom: 1px green solid;
border-top: none;
border-right: none;
border-left: none;
}
.form-input::before {
content: '';
position: absolute;
background-color: green;
left: 0;
bottom: 0;
width: 0;
height: 2px;
transition: ease-out 300ms;
}
.form-input:hover::before {
width: 100%;
}
.form-input:focus-within::before {
width: 100%;
}
.form-input input {
border: none;
width: 100%;
}
.form-input input:focus-visible {
outline: none;
}
.field {
position: relative;
margin-bottom: 15px;
vertical-align: bottom;
}
.field label::before {
content: attr(title);
position: absolute;
top: 0;
left: 15px;
line-height: 40px;
font-size: 14px;
color: #777;
transition: 300ms all;
}
.field input {
width: 100%;
line-height: 40px;
padding: 0 8px;
box-sizing: border-box;
font-size: 14px;
color: green;
vertical-align: bottom;
}
Place this at the bottom of the CSS section:
input[type=text] {
height: 15px;
}

React JS collapsable elements Pure CSS

How can i make Netflix like Collapsable QNA sectionImage 1 click here
image 2
You don't need JS for this task
body {
margin: 0;
background-color: #000;
font-family: sans-serif;
}
.faq_block {
margin: 30px 0 85px
}
.faq_item {
border-radius: 20px;
padding: 0;
margin-bottom: 10px
}
.faq_item:focus .faq_question,
.faq_item:hover .faq_question {
color: #d5f867
}
.faq_item:focus .faq_question:after,
.faq_item:focus .faq_question:before,
.faq_item:hover .faq_question:after,
.faq_item:hover .faq_question:before {
background: #d5f867
}
.faq_item:before {
display: none
}
.faq_question {
font-weight: 700;
position: relative;
display: block;
font-size: 16px;
color: #fff;
border-radius: 20px;
cursor: pointer
}
.faq_question:after,
.faq_question:before {
content: "";
position: absolute;
background-color: #fff;
z-index: 2
}
.faq_question:after {
right: 17px;
top: 24px;
width: 14px;
height: 2px
}
.faq_question:before {
height: 14px;
width: 2px;
right: 23px;
top: 18px
}
.faq_item[open] .faq_question {
background: #d5f867;
color: #000
}
.bl_ceo .faq_answer ul li:before,
.faq_item[open] .faq_question:after {
background-color: #000
}
.faq_item[open] .faq_question:before {
opacity: 0
}
.faq_item[open] {
background-color: #fff
}
.faq_answer,
.faq_question {
padding: 16px 24px
}
.faq_item[open] .faq_answer,
.faq_item[open] .faq_answer li,
.faq_item[open] .faq_answer p {
color: #000
}
<div class="faq_block">
<details class="faq_item" open="">
<summary class="faq_question">Ask something smart!</summary>
<div class="faq_answer">Answer</div>
</details>
<details class="faq_item">
<summary class="faq_question">Ask something smart!</summary>
<div class="faq_answer">Answer</div>
</details>
</div>

Custom Checkbox without label [duplicate]

This question already has answers here:
What are the various ways to hide a <div>?
(5 answers)
Can I have an onclick effect in CSS?
(14 answers)
Closed 2 years ago.
I have an a element that acts like a toggle button :
var container = document.getElementsByClassName("favorite");
for (var i = 0; i < container.length; i++) {
//For each element in the container array, add an onclick event.
container[i].onclick = function(event) {
this.classList.toggle('selected');
}
}
body {
background-color: #04246A;
}
.container {
position: relative;
width: 204px;
max-width: 204px;
height: 82px;
max-height: 82px;
padding: 24px;
background: #fff;
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
color: black;
list-style: none;
border: 2px solid black;
}
.container .favorite {
position: absolute;
top: 10px;
right: 10px;
width: 40px;
height: 40px;
display: flex;
border-radius: 50%;
cursor: pointer;
}
.container .favorite:hover {
background: #D9DEEA;
}
.container .favorite::after {
z-index: 2;
position: relative;
margin: auto;
height: 20px;
content: url("https://img.icons8.com/ios/16/000000/star.png");
}
.container .favorite.selected::after {
content: url("https://img.icons8.com/ios-filled/16/000000/star.png");
}
.container dl {
margin: 0;
}
.container dl dt {
display: block;
font-size: 12px;
color: #6B7790;
}
.container dl dd {
margin: 0;
font-weight: normal;
color: #04246A;
}
<div class="container">
<a class="favorite"></a>
<dl>
<dt>Ref</dt>
<dd>XXX123</dd>
</dl>
</div>
I want to transform it to a checkbox, but the solutions I find are for a checkbox with a label, I only want to use the checkbox in my html without the label or some additional div, this is what I tried :
body {
background-color: #04246A;
}
.container {
position: relative;
width: 204px;
max-width: 204px;
height: 82px;
max-height: 82px;
padding: 24px;
background: #fff;
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
color: black;
list-style: none;
border: 2px solid black;
}
input[type="checkbox"]{
height: 20px;
width: 20px;
position: absolute;
opacity: 1;
margin: auto;
height: 20px;
cursor: pointer;
top: 10px;
right: 10px;
}
input[type="checkbox"]::after{
content: url("https://img.icons8.com/ios/16/000000/star.png");
position: absolute;
top: 0;
left: 0;
border-radius: 50%;
margin: auto;
height: 20px;
width: 20px;
pointer-events: none;
}
input[type="checkbox"]:checked:after {
content: url("https://img.icons8.com/ios-filled/16/000000/star.png");
}
input[type="checkbox"]:hover:after{
background: #D9DEEA;
}
.container dl {
margin: 0;
}
.container dl dt {
display: block;
font-size: 12px;
color: #6B7790;
}
.container dl dd {
margin: 0;
font-weight: normal;
color: #04246A;
}
<div class="container">
<input type="checkbox" />
<dl>
<dt>Ref</dt>
<dd>XXX123</dd>
</dl>
</div>
Which doesn't look good.
How can I fix this ? and thanks in advance.
You can add appearance:none to remove to checkbox appearance and set fixed height/width to checkbox and :after, changing :after to flex allows you to center the background.
body {
background-color: #04246A;
}
.container {
position: relative;
width: 204px;
max-width: 204px;
height: 82px;
max-height: 82px;
padding: 24px;
background: #fff;
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
color: black;
list-style: none;
border: 2px solid black;
}
input[type="checkbox"]{
height: 40px;
width: 40px;
position: absolute;
opacity: 1;
margin: auto;
cursor: pointer;
top: 10px;
right: 10px;
appearance: none;
outline: none;
}
input[type="checkbox"]::after{
content: url("https://img.icons8.com/ios/16/000000/star.png");
position: absolute;
top: 0;
left: 0;
border-radius: 50%;
margin: auto;
height: 40px;
width: 40px;
pointer-events: none;
display: flex;
justify-content: center;
align-items: center;
}
input[type="checkbox"]:checked:after {
content: url("https://img.icons8.com/ios-filled/16/000000/star.png");
}
input[type="checkbox"]:hover:after{
background: #D9DEEA;
}
.container dl {
margin: 0;
}
.container dl dt {
display: block;
font-size: 12px;
color: #6B7790;
}
.container dl dd {
margin: 0;
font-weight: normal;
color: #04246A;
}
<div class="container">
<input type="checkbox" />
<dl>
<dt>Ref</dt>
<dd>XXX123</dd>
</dl>
</div>

Responsive Design Fail

I am having an issue with trying to figure out why the header on my mobile format isn't showing up.... can anyone see something I can't?? I have been trying for two weeks and I must be missing something. It appears that my larger version is working just fine, but I would appreciate any help I can get with this problem. Thank you.
/* very small mobile styles */
#media only screen and (max-width: 320px) {
html,
body {
margin: 0;
width: auto;
background-color: #682876;
}
.container-header {
display: none;
}
.container-header-mobile {
height: 260px;
width: 100%;
position: relative;
text-align: center;
color: #682876;
background-color: white;
padding: 0;
}
.container-header-mobile img {
max-height: 100px;
min-height: 50px;
width: auto;
}
.container-header-mobile a {
text-decoration: none;
padding: 0 5px;
}
main {
text-align: center;
color: white;
padding: 0;
margin: 0;
}
main img {
max-width: 300px;
height: auto;
padding: 0;
}
figure {
display: inline-block;
position: relative;
overflow: hidden;
margin: 0;
}
figcaption {
position: absolute;
font-family: "Montserrat", sans-serif;
font-size: 1.5em;
font-weight: bold;
background: rgba(104, 40, 118, 0.5);
color: #ffffff;
padding: 20px 20px;
opacity: 0;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
figure:hover figcaption {
opacity: 1;
left: 0;
}
.cap-bot figcaption {
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
bottom: 0;
}
h1 {
font-family: "Caveat", cursive;
font-weight: lighter;
font-size: 0.75em;
}
p {
font-family: "Montserrat", sans-serif;
font-size: 0.5em;
}
main a {
color: white;
text-decoration: none;
}
.bot-social {
margin: auto;
}
.bot-social img {
border-radius: 18px;
}
footer {
color: white;
text-align: center;
margin: 0;
padding: 10px;
}
footer a {
color: white;
text-decoration: none;
}
}
/* mobile portrait styles */
#media only screen and (max-width: 768px) {
html,
body {
margin: 0;
width: auto;
background-color: #682876;
}
.container-header {
display: none;
}
.container-header-mobile {
height: 260px;
width: 100%;
text-align: center;
position:relative;
color: #682876;
background-color: white;
padding: 0;
}
.container-header-mobile img {
max-height: 100px;
min-height: 50px;
width: auto;
}
.container-header-mobile a {
text-decoration: none;
padding: 0 5px;
}
main {
text-align: center;
color: white;
padding: 15px 2%;
margin: 0;
}
main img {
max-width: 370px;
height: auto;
padding: 5px;
}
figure {
display: inline-block;
position: relative;
overflow: hidden;
margin: 0;
}
figcaption {
position: absolute;
font-family: "Montserrat", sans-serif;
font-size: 1.5em;
background: rgba(104, 40, 118, 0.5);
color: #ffffff;
padding: 20px 20px;
opacity: 0;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
figure:hover figcaption {
opacity: 1;
left: 0;
}
.cap-bot figcaption {
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
bottom: 0;
}
h1 {
font-family: "Caveat", cursive;
font-weight: lighter;
font-size: 1em;
}
p {
font-family: "Montserrat", sans-serif;
font-size: 0.5em;
}
main a {
color: white;
text-decoration: none;
}
.bot-social {
margin: auto;
}
.bot-social img {
border-radius: 18px;
}
footer {
color: white;
text-align: center;
margin: 0;
padding: 10px;
}
footer a {
color: white;
text-decoration: none;
}
}
/* laptop styles */
#media only screen and (max-width: 1024px) {
html,
body {
margin: 0;
width: auto;
background-color: #682876;
}
.container-header-mobile {
display: none;
}
.container-header {
height: 260px;
width: 100%;
position: relative;
text-align: center;
color: #682876;
background-color: white;
}
.container-header a {
text-decoration: none;
padding: 0 5px;
}
.container-header img {
max-height: 230px;
width: auto;
padding-right: 12%;
}
.bot-social {
display: none;
}
.top-left {
position: absolute;
top: 8px;
left: 16px;
}
.top-right {
position: absolute;
top: 8px;
right: 16px;
}
.top-left img {
padding: 5px;
}
main {
text-align: center;
color: white;
padding: 15px 2%;
margin: 0;
}
main img {
max-width: 370px;
height: auto;
padding: 10px;
}
figure {
display: inline-block;
position: relative;
overflow: hidden;
margin: 0;
}
figcaption {
position: absolute;
font-family: "Montserrat", sans-serif;
font-size: 1.5em;
background: rgba(104, 40, 118, 0.5);
color: #ffffff;
padding: 20px 20px;
opacity: 0;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
figure:hover figcaption {
opacity: 1;
left: 0;
}
.cap-bot figcaption {
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
bottom: 0;
}
h1 {
font-family: "Caveat", cursive;
font-weight: lighter;
font-size: 2em;
}
p {
font-family: "Montserrat", sans-serif;
font-size: 1em;
}
main a {
color: white;
text-decoration: none;
}
.bot-social {
margin: auto;
}
footer {
color: white;
text-align: center;
margin: 0;
padding: 10px;
}
footer a {
color: white;
text-decoration: none;
}
}
/* large laptop styles */
#media only screen and (max-width: 1362px) {
html,
body {
margin: 0;
width: auto;
background-color: #682876;
}
.container-header-mobile {
display: none;
}
.container-header {
height: 260px;
width: 100%;
position: relative;
text-align: center;
color: #682876;
background-color: white;
}
.container-header a {
text-decoration: none;
padding: 0 5px;
}
.container-header img {
max-height: 230px;
width: auto;
padding-right: 12%;
}
.bot-social {
display: none;
}
.top-left {
position: absolute;
top: 8px;
left: 16px;
}
.top-right {
position: absolute;
top: 8px;
right: 16px;
}
.top-left img {
padding: 5px;
}
main {
text-align: center;
color: white;
padding: 15px 2%;
margin: 0;
}
main img {
width: 236px;
height: auto;
padding: 10px;
}
figure {
display: inline-block;
position: relative;
overflow: hidden;
margin: 0;
}
figcaption {
position: absolute;
font-family: "Montserrat", sans-serif;
font-size: 1.5em;
background: rgba(104, 40, 118, 0.5);
color: #ffffff;
padding: 20px 20px;
opacity: 0;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
figure:hover figcaption {
opacity: 1;
left: 0;
}
.cap-bot figcaption {
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
bottom: 0;
}
h1 {
font-family: "Caveat", cursive;
font-weight: lighter;
font-size: 2em;
}
p {
font-family: "Montserrat", sans-serif;
font-size: 1em;
}
main a {
color: white;
text-decoration: none;
}
.bot-social {
margin: auto;
}
footer {
color: white;
text-align: center;
margin: 0;
padding: 10px;
}
footer a {
color: white;
text-decoration: none;
}
}
/* desktop styles */
#media only screen and (max-width: 1440px) {
html,
body {
margin: 0;
width: auto;
background-color: #682876;
}
.container-header-mobile {
display: none;
}
.container-header {
height: 260px;
width: 100%;
position: relative;
text-align: center;
color: #682876;
background-color: white;
}
.container-header a {
text-decoration: none;
padding: 0 5px;
}
.container-header img {
max-height: 230px;
width: auto;
padding-right: 12%;
}
.bot-social {
display: none;
}
.top-left {
position: absolute;
top: 8px;
left: 16px;
}
.top-right {
position: absolute;
top: 8px;
right: 16px;
}
.top-left img {
padding: 5px;
}
main {
text-align: center;
color: white;
padding: 15px 2%;
margin: 0;
}
main img {
max-width: 500px;
height: auto;
padding: 10px;
}
figure {
display: inline-block;
position: relative;
overflow: hidden;
margin: 0;
}
figcaption {
position: absolute;
font-family: "Montserrat", sans-serif;
font-size: 1.5em;
background: rgba(104, 40, 118, 0.5);
color: #ffffff;
padding: 20px 20px;
opacity: 0;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
figure:hover figcaption {
opacity: 1;
left: 0;
}
.cap-bot figcaption {
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
bottom: 0;
}
h1 {
font-family: "Caveat", cursive;
font-weight: lighter;
font-size: 2em;
}
p {
font-family: "Montserrat", sans-serif;
font-size: 1em;
}
main a {
color: white;
text-decoration: none;
}
.bot-social {
margin: auto;
}
footer {
color: white;
text-align: center;
margin: 0;
padding: 10px;
}
footer a {
color: white;
text-decoration: none;
}
}
/* HD styles */
#media only screen and (min-width: 1441px) {
html,
body {
margin: 0;
width: auto;
background-color: #682876;
}
.container-header-mobile {
display: none;
}
.container-header {
height: 260px;
width: 100%;
position: relative;
text-align: center;
color: #682876;
background-color: white;
}
.container-header a {
text-decoration: none;
padding: 0 5px;
}
.container-header img {
max-height: 230px;
width: auto;
padding-right: 12%;
}
.bot-social {
display: none;
}
.top-left {
position: absolute;
top: 8px;
left: 16px;
}
.top-right {
position: absolute;
top: 8px;
right: 16px;
}
.top-left img {
padding: 5px;
}
main {
text-align: center;
color: white;
padding: 15px 2%;
margin: 0;
}
main img {
max-width: 300%;
height: auto;
padding: 10px;
}
figure {
display: inline-block;
position: relative;
overflow: hidden;
margin: 0;
}
figcaption {
position: absolute;
font-family: "Montserrat", sans-serif;
font-size: 1.5em;
background: rgba(104, 40, 118, 0.5);
color: #ffffff;
padding: 20px 20px;
opacity: 0;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
figure:hover figcaption {
opacity: 1;
left: 0;
}
.cap-bot figcaption {
left: 0;
bottom: -30%;
}
.cap-bot:hover figcaption {
bottom: 0;
}
h1 {
font-family: "Caveat", cursive;
font-weight: lighter;
font-size: 2em;
}
p {
font-family: "Montserrat", sans-serif;
font-size: 1em;
}
main a {
color: white;
text-decoration: none;
}
.bot-social {
margin: auto;
}
footer {
color: white;
text-align: center;
margin: 0;
padding: 10px;
}
footer a {
color: white;
text-decoration: none;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Volume Salon Westlake</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Caveat|Montserrat" rel="stylesheet">
<link rel="stylesheet" href="normalize.css">
<link rel="stylesheet" href="main.css">
</head>
<body>
<header>
<div class="container-header">
<div class="top-left">
<a href="https://www.facebook.com/volumesalonwestlake/" target="_blank">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/FB-f-Logo__blue_29.png" alt="Facebook">
</a>
<a href="https://www.instagram.com/explore/locations/1732209880415699/volume-salon/" target="_blank">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/glyph-logo_May2016.png" alt="Instagram">
</a>
</div>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/header.jpg" alt="VS Logo">
<div class="top-right">
<p><b>26101 Center Ridge Rd. Westlake, OH 44145</b></p>
</div>
</div>
<div class="container-header-mobile">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/header.jpg" alt="VS Logo"><br>
<p><b>26101 Center Ridge Rd. Westlake, OH 44145</b></p>
</div>
</header>
<main>
<div>
<h1>Volume Salon, located in Westlake, Ohio is... To view offered services and schedule an appointment with one of our independent sylists, visit the links below:</h1>
</div>
<div>
<figure class="cap-bot">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/nikki.png" alt="Nikki">
<figcaption>Nikki</figcaption>
</figure>
<figure class="cap-bot">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/kevin.png" alt="Kevin">
<figcaption>Kevin</figcaption>
</figure>
<figure class="cap-bot">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/kelley2.png" alt="Kelley">
<figcaption>Kelley</figcaption>
</figure>
<figure class="cap-bot">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/anne-marie.jpg" alt="Anne-Marie">
<figcaption>Anne-Marie</figcaption>
</figure>
</div>
<div class="bot-social">
<a href="https://www.facebook.com/volumesalonwestlake/" target="_blank">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/FB-f-Logo__blue_29.png" alt="Facebook">
</a>
<a href="https://www.instagram.com/explore/locations/1732209880415699/volume-salon/" target="_blank">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1671394/glyph-logo_May2016.png" alt="Instagram">
</a>
</div>
<br><br><br>
</main>
<footer>
<p>© 2018 Volume Salon</p>
<p>Made with ♥ by Valarie Pisarcik</p>
</footer>
</body>
</html>
your header doesn't show up in width fewer than 320px because you set dispaly: none.
.container-header {
display: none;
}
please change it to :
.container-header {
display: block;
}
See if this helps you:
https://codepen.io/panchroma/pen/NBaNXv
Remember that CSS code cascades. If your stylesheet has
.element{
display:block;
}
.....
.element{
display:none;
}
then the display property for .element will be none.
In your CSS code you have
#media only screen and (max-width: 320px) {
.container-header-mobile {
height: 260px;
width: 100%;
position: relative;
text-align: center;
color: #682876;
background-color: white;
padding: 0;
}
}
...
#media only screen and (max-width: 1024px) {
.container-header-mobile {
display: none;
}
}
There are two ways to stop one media query from overriding another.
In my pen I modified your media queries by adding a (min-width) to each of them, eg
#media only screen and (max-width: 320px) {
...
}
#media only screen and (min-width: 321px) and (max-width: 768px) {
...
}
#media only screen and (min-width: 769px) and (max-width: 1024px) {
...
}
the other option is to reverse the order of your media queries, have the desktop viewport first and the mobile viewport last:
#media only screen and (min-width: 1441px) {
...
}
#media only screen and (max-width: 1440px) {
...
}
#media only screen and (max-width: 1362px) {
...
}
Hope this helps!

Resources