On the media queries on one of my portfolio pages, regardless of what I set my font to, it won't change for mobile or desktop. I've tried using px, em, and vw and it still won't change. The font size works well on desktop, but I'd like it to be just a little smaller on mobile.
css
<style>
.tiffany {
/*border: solid green 3px;*/
width:100%;
height:100%;
}
.tiffany img {
width: 100%;
height: 100%;
position: relative;
}
#media only screen and (max-width: 480px) {
.tiffany img {
width: 300px;
height: 225px;
}
}
.tiffany .textbox {
/*border: solid red 3px;*/
position: absolute;
margin: 32px;
font-weight: bold;
text-align: left;
font-size: 5vw;
}
#media only screen and (max-width: 480px) {
.tiffany .textbox {
font-size: 2vw;
position: absolute;
margin: 0px;
padding: 0px;
left: 10px;
font-weight: bold;
text-align: left;
}
}
.tiffany .gradient {
/*border: solid red 3px;*/
left: 0px;
top: 0px;
z-index: 1000;
position: absolute;
width: 100%;
height: 100%;
/* other styles (left, top, right, and padding) */
background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
}
/* read-here */
.read-here {
position: absolute;
bottom: 4vw;
left: 50px;
background-color: rgb(0, 68, 11);
color: rgb(0, 68, 11);
padding: 16px;
font-size: 16px;
border: none;
font color: rgb(255, 255, 255)
}
#media only screen and (max-width: 480px) {
/* read-here */
.read-here {
position: absolute;
bottom: 4vw;
left: 10px;
background-color: rgb(0, 68, 11);
color: rgb(0, 68, 11);
padding: 8px;
font-size: 10px;
border: none;
font color: rgb(255, 255, 255)
}
}
html
</style>
<div class="tiffany">
<img class="background-image" src="https://freight.cargo.site/t/original/i/49f84023695066f70817f10d5164bfc85e438f33abd59b9c50a439f6a22f0454/Featured-Page_Tiffany_Alfonseca_Latina_Edit.jpeg">
<div class="gradient">
<div class="textbox full-pointer-events-none">
<h1>Tiffany Alfonseca Pays Homage in Painting</h1>
<br>
</div>
<div class="read-here">
<bodycopy> <b>Read here</b> </bodycopy>
</div>
</div>
<br></div>
You need to add !important to force the CSS for your #media.
No need to write all the class properties in the #media if no changes
#media only screen and (max-width: 480px) {
/* No need to write all properties of the class if no changes */
.read-here {
font-size: 10px !important;
padding: 8px; !important
left: 10px; !important
}
}
Do the same for the other classes.
Update :
<style>
.tiffany {
/*border: solid green 3px;*/
width: 100%;
height: 100%;
}
.tiffany img {
width: 100%;
height: 100%;
position: relative;
}
#media only screen and (max-width: 480px) {
.tiffany img {
width: 300px;
height: 225px;
}
}
.tiffany .textbox {
/*border: solid red 3px;*/
position: absolute;
margin: 32px;
font-weight: bold;
text-align: left;
font-size: 5vw;
}
#media only screen and (max-width: 480px) {
.tiffany .textbox {
font-size: 2vw;
position: absolute;
margin: 0px;
padding: 0px;
left: 10px;
font-weight: bold;
text-align: left;
}
}
.tiffany .gradient {
/*border: solid red 3px;*/
left: 0px;
top: 0px;
z-index: 1000;
position: absolute;
width: 100%;
height: 100%;
/* other styles (left, top, right, and padding) */
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent);
}
/* read-here */
.read-here {
position: absolute;
bottom: 4vw;
left: 50px;
background-color: rgb(0, 68, 11);
color: rgb(0, 68, 11);
padding: 16px;
font-size: 16px;
border: none;
font-color: rgb(255, 255, 255);
}
#media only screen and (max-width: 480px) {
/* No need to write all properties of the class if no changes */
.read-here {
font-size: 10px !important;
padding: 8px; !important
left: 10px; !important
}
}
</style>
<div class="tiffany">
<img
class="background-image"
src="https://freight.cargo.site/t/original/i/49f84023695066f70817f10d5164bfc85e438f33abd59b9c50a439f6a22f0454/Featured-Page_Tiffany_Alfonseca_Latina_Edit.jpeg"
/>
<div class="gradient">
<div class="textbox full-pointer-events-none">
<h1>Tiffany Alfonseca Pays Homage in Painting</h1>
<br />
</div>
<div class="read-here">
<bodycopy>
<b
><a
href="https://latina.com/tiffany-alfonseca-pays-homage-in-painting/"
target="_blank"
>Read here</a
></b
>
</bodycopy>
</div>
</div>
<br />
</div>
Related
I have zero coding experience and have been working on my portfolio using cargo. I'm currently trying to adjust the mobile view of one of my articles on my home page using media queries, but the code seems to change the layout on desktop as well. I'll drop reference pictures below of the desired mobile and desktop views, as well as the current code I'm working with. Any help is appreciated, thanks!
**(disregard the borders in the code, this was mostly for visibility purposes when making changes)
Here's my code:
<style>
.tiffany {
/*border: solid green 3px;*/
width: 100%;
height: 100%;
}
.tiffany img {
width: 100%;
height: 100%;
position: relative;
}
.tiffany .textbox {
/*border: solid red 3px;*/
position: absolute;
margin: 32px;
font-weight: bold;
text-align: left;
}
.resize_tiffany {
font-size: 5vw;
}
.tiffany .gradient {
/*border: solid red 3px;*/
left: 0px;
top: 0px;
z-index: 1000;
position: absolute;
width: 100%;
height: 100%;
/* other styles (left, top, right, and padding) */
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent);
}
/* read-here */
.read-here {
position: absolute;
bottom: 4vw;
left: 50px;
background-color: rgb(0, 68, 11);
color: rgb(0, 68, 11);
padding: 16px;
font-size: 16px;
border: none;
font color: rgb(255, 255, 255)
}
#media only screen and (max-width: 480) {
.tiffany .textbox {
border: solid blue 3px;
position: absolute;
margin: 15px;
font-weight: bold;
text-align: left;
}
#media only screen and (max-width: 480) {
/* read-here */
.read-here {
position: absolute;
bottom: 4vw;
left: 10px;
background-color: rgb(0, 68, 11);
color: rgb(0, 68, 11);
padding: 8px;
font-size: 16px;
border: none;
font color: rgb(255, 255, 255)
}
}
</style>
<div class="tiffany">
<img class="background-image" src="https://freight.cargo.site/t/original/i/49f84023695066f70817f10d5164bfc85e438f33abd59b9c50a439f6a22f0454/Featured-Page_Tiffany_Alfonseca_Latina_Edit.jpeg">
<div class="gradient">
<div class="textbox full-pointer-events-none">
<h1> <span class="resize_tiffany">Tiffany Alfonseca Pays Homage in Painting</span></h1>
<br>
</div>
<div class="read-here">
<bodycopy> <b>Read here</b> </bodycopy>
</div>
</div>
<br></div>
You haven't added in the px like so:
#media only screen and (max-width: 480px)
{
}
Also I would highly recommend using rem instead of vw for the font-size. You can read more about that on: https://www.freecodecamp.org/news/what-is-rem-in-css/
Essentially, If you don't specify font-size the default is 16px, 1rem would therefore be equal to 16px, 2rem = 32px and so on.
I got autocomplete dropdown filled with almost solid background colour
.Suggestions {
text-align: left;
position: absolute;
border: 1px solid #ddd;
border-radius: 5px;
background-color: rgba(235, 235, 235, 0.95);
list-style: none;
margin-top: -9px;
max-height: 143px;
overflow-y: auto;
padding-left: 0;
width: 406px;
}
covering other elements (buttons, inputs ...) when activated
DEACTIVATED
ACTIVATED
and I would like to make an effect similar to safari dropdown when clicked on url where everything behind is almost visible and also blurred.
Is there any way to do that in css? I know that I can create an image and then apply blur filter but the autocomplete is used in many screens with different background so creating image for each screen would be a mammoth task
function myFunction() {
var Textfield = document.getElementById("Textfield");
if (Textfield.value == "")
document.getElementById("back_div").classList.remove("blur");
else
document.getElementById("back_div").classList.add("blur");
}
.blur {
/* Add the blur effect */
filter: blur(2.5px);
-webkit-filter: blur(2.5px);
}
<input id="Textfield" onkeyup="myFunction()" type="text">
<div id="back_div">test text</div>
This question speaks to blur Can you blur the content beneath/behind a div?
There is also opacity going on there as well, here are some ugly things to demonstrate that.
This is somewhat difficult to answer as it does depend on your markup a bit - and CSS pure vs some JavaScript are in some cases very different. here are some things.
.my-select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: .4em;
background: rgba(235, 235, 235, 0.8);
border: none;
border-radius: 0.5em;
padding: 1em 2em 1em 1em;
font-size: 1em;
}
/* the triagle arrow */
.select-container {
position: relative;
display: inline;
}
/* the triagle arrow */
.select-container:after {
content: "";
width: 0;
height: 0;
position: absolute;
pointer-events: none;
}
/* the triagle arrow */
.select-container:after {
border-left: 5px solid transparent;
border-right: 5px solid transparent;
top: .3em;
right: .75em;
border-top: 8px solid black;
opacity: 0.5;
}
.my-select::-ms-expand {
display: none;
}
.my-select:focus {
outline: none;
border-radius: 0.5em;
}
select.my-select * {
background: rgba(235, 235, 235, 0.8);
opacity: 0.8;
color: lightorange;
}
select.my-select * {
background-color: #bbeeee;
color: #226666;
opacity: 8;
}
select.my-select *:focus {
background: rgba(235, 135, 100, 0.5);
opacity: 0.8;
}
.list-container>.my-list:hover {
opacity: 0.6;
}
.list-container .my-list li:hover {
color: lime;
);
}
.something {
font-size: 2em;
position: relative;
top: -0.7em;
z-index: -2
}
.my-list {
padding-top: 0.4em;
background: rgba(240, 240, 200, 0.9);
border: none;
border-radius: 0.5em;
padding: 1em 1.5em 1em 1em;
font-size: 1.4em;
border: solid 0.25px green;
}
.my-list li {
color: #227777;
list-style-type: square;
}
.other {
color: red;
font-size: 2em;
background-color: lightblue;
position: relative;
top: -2.5em;
left: 1px;
height: 3em;
z-index: -1;
}
.test-backdrop-container {
height: 10em;
border: 1px dotted red;
font-size: 2em;
position: relative;
}
.test-backdrop {
position: relative;
size: 1.5em;
top: 0.75em;
left: 0.75em;
border: solid blue 1px;
background-color: #dddddd;
}
.test-backdrop {
-webkit-backdrop-filter: blur(10px);
opacity: 0.8;
}
<div class="select-container">
<select class="my-select">
<option>one wider text</option>
<option>two</option>
<option>eagle</option>
<option>canary</option>
<option>crow</option>
<option>emu</option>
</select>
</div>
<div class="something">something here</div>
<div class="list-container">
<ul class="my-list">
<li>one wider text</li>
<li>two</li>
<li>eagle</li>
<li>canary</li>
<li>crow</li>
<li>emu</li>
</ul>
</div>
<div class="other">Tester out
<input class="other-input" type="text" value="something in textbox" /> More is not more but not less
</div>
<div class="test-backdrop-container">Test Container
<div class="test-backdrop">Test Backdrop</div>
more text in container more test text
</div>
I've a simple page containing: a header, a topnav and a body.
The topnav would contain a link (variable width since it will be the name of the logged user) to open a dropdown menu.
Problem: The dropdown menu is "cropped" by the topnav.
I've tried the z-index solution, but no success.
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16pt;
}
.header {
background-color: #F1F1F1;
text-align: center;
padding: 20px;
font-size: 18pt;
font-weight: bold;
}
.topnav {
position: relative;
top:0;
overflow: hidden;
background-color: #333;
font-weight: bold;
z-index: 1;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
cursor:pointer
}
.topnav a:hover {
transition-delay: 70ms;
background-color: #ddd;
color: black;
}
.active {
background-color: #4CAF50;
color: white;
}
.dropdown {
position: absolute;
display: inline-block;
float: right;
overflow: hidden;
margin: 0;
z-index: 100;
}
.dropdown-content {
display: none;
position: absolute;
top: 70%;
padding-top: 0px;
color: #f2f2f2;
background-color: blue;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 200;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
/* Finestra modal */
.container {
padding: 30px;
}
span.psw {
float: right;
padding-top: 16px;
}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 30%; /* Could be more or less, depending on screen size */
}
/* Full-width input fields */
.modal input[type=text], .modal input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
/* Set a style for all buttons */
.modal button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
font-weight: bold;
}
.imgcontainer {
font-weight: bold;
text-align: center;
margin: 24px 0 12px 0;
position: relative;
}
/* The Close Button (x) */
.close {
position: absolute;
right: 9px;
top: -20px;
color: #000;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
/* Add Zoom Animation */
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}
}
#keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* Change styles for span and cancel button on extra small screens */
#media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
<link rel="stylesheet" href="css/topnav.css">
<!-- HEADER -->
<div class="header">
Sistema di Gestione
</div>
<!-- BARRA MENU -->
<div class="topnav" id="navbar">
<a class="active" href="index.php">Home</a>
Segnalazioni
<div class="dropdown"><a>Dropdown></a>
<div class="dropdown-content"><a>BANANA</a></div>
</div>
</div>
<!-- Form di Login -->
<div id="finestra" class="modal">
<div class="modal-content">
<form class="login" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="imgcontainer">
<span onclick="document.getElementById('finestra').style.display='none'" class="close" title="Chiudi finestra">×</span>
</div>
<div class="container">
<input type="text" placeholder="Username" name="username" required>
<input type="password" placeholder="Password" name="password" required>
<button type="submit" name="login" value="login">Login</button>
</div>
</form>
</div>
</div>
<!-- Script per chiudere il modal -->
<script>
// Get the modal
var modal = document.getElementById('finestra');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
Your issue with overflow:hidden given in parent divs of dropdown.
Changed below css
.topnav {
position: relative;
top: 0;
/* overflow: hidden; */ // Removed
background-color: #333;
font-weight: bold;
z-index: 1;
display: block;
width: 100%; // Added
height: 48px; // Added
}
.dropdown {
position: absolute;
display: inline-block;
float: right;
/* overflow: hidden; */ // Removed
margin: 0;
z-index: 100;
}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16pt;
}
.header {
background-color: #F1F1F1;
text-align: center;
padding: 20px;
font-size: 18pt;
font-weight: bold;
}
.topnav {
position: relative;
top:0;
/* overflow: hidden; */
background-color: #333;
font-weight: bold;
z-index: 1;
width: 100%;
height: 48px;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
cursor:pointer
}
.topnav a:hover {
transition-delay: 70ms;
background-color: #ddd;
color: black;
}
.active {
background-color: #4CAF50;
color: white;
}
.dropdown {
position: absolute;
display: inline-block;
float: right;
/*overflow: hidden;*/
margin: 0;
z-index: 100;
}
.dropdown-content {
display: none;
position: absolute;
top: 70%;
padding-top: 0px;
color: #f2f2f2;
background-color: blue;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 200;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
/* Finestra modal */
.container {
padding: 30px;
}
span.psw {
float: right;
padding-top: 16px;
}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 30%; /* Could be more or less, depending on screen size */
}
/* Full-width input fields */
.modal input[type=text], .modal input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
/* Set a style for all buttons */
.modal button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
font-weight: bold;
}
.imgcontainer {
font-weight: bold;
text-align: center;
margin: 24px 0 12px 0;
position: relative;
}
/* The Close Button (x) */
.close {
position: absolute;
right: 9px;
top: -20px;
color: #000;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
/* Add Zoom Animation */
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}
}
#keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* Change styles for span and cancel button on extra small screens */
#media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
<link rel="stylesheet" href="css/topnav.css">
<!-- HEADER -->
<div class="header">
Sistema di Gestione
</div>
<!-- BARRA MENU -->
<div class="topnav" id="navbar">
<a class="active" href="index.php">Home</a>
Segnalazioni
<div class="dropdown"><a>Dropdown></a>
<div class="dropdown-content"><a>BANANA</a></div>
</div>
</div>
<!-- Form di Login -->
<div id="finestra" class="modal">
<div class="modal-content">
<form class="login" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="imgcontainer">
<span onclick="document.getElementById('finestra').style.display='none'" class="close" title="Chiudi finestra">×</span>
</div>
<div class="container">
<input type="text" placeholder="Username" name="username" required>
<input type="password" placeholder="Password" name="password" required>
<button type="submit" name="login" value="login">Login</button>
</div>
</form>
</div>
</div>
<!-- Script per chiudere il modal -->
<script>
// Get the modal
var modal = document.getElementById('finestra');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
I need to have a image on div background. Over this image, its mandatory to have one title, subtitle and a button.
All these three elements need to have top and left in % for dynamic position.
I had made several tries, but without success.
HTML
<div id="container">
<div id="block1">
<div id="title">LIAM</div>
<div id="subtitle">SUPER SLIM FIT</div>
<div id="link">
See all jeans
</div>
</div>
</div>
CSS
#block1 {
background-image: url('http://tiffosi.com/fw16/img/img1.jpg');
background-repeat: no-repeat;
background-size: contain;
width: 100%;
height: 1450px;
max-width: 1086px;
max-height: 1450px;
position: relative;
top: 0;
left: 0;
}
#block1 #subtitle {
font-size: 16pt;
color: white;
position: absolute;
top: 23.4%;
left: 43.5%;
letter-spacing: 1px;
}
#block1 #link {
width: 184px;
text-align: center;
height: 43px;
line-height: 43px;
border: 1px solid white;
font-size: 11pt;
top: 29.3%;
left: 41.3%;
position: absolute;
}
#block1 #link a {
color: white;
text-decoration: none;
font-weight: 100;
}
#media only screen and (min-width : 768px) {
#block1 #title{
top: 12%;
left:42%;
font-size:80%;
}
}
#media only screen and (min-width : 992px) {
#block1 #title {
font-size: 100%;
position: absolute;
top: 16.5%;
left: 42%;
letter-spacing: 2px;
}
}
#block1 #title {
font-size: 97px;
color: white;
position: absolute;
top: 16.5%;
left: 42%;
letter-spacing: 2px;
}
Link to jsffidle: https://jsfiddle.net/jggscada/
instead of positioning each element individually , i suggest you give position:absolute to #block1 and position it on the image ( image as background to #container or make another div surrounding the #block1 div ) .
i used top:40vh -> vh=viewport height
and then position the elements inside the block1 as you desire.
also i deleted the #link div and added styles directly to the link instead. seems more logical this way :) . if you want a link to behave like a div use display:block , in this case i used display:inline-block
VERY IMPORTANT : do not use fixed width and height if you want something to be responsive. i used width:100vw on .container so it has the width of the screen.
see snippet below or fiddle here > Jsfiddle
let me know if it works for you
#container {
background-image: url('http://tiffosi.com/fw16/img/img1.jpg');
background-repeat: no-repeat;
background-size: contain;
width: 100vw;
height: 1450px;
max-width: 1086px;
max-height: 1450px;
position: relative;
top: 0;
left: 0;
border: 1px solid red;
}
#block1 #title {
font-family: oswald-bold;
font-size: 60pt;
color: white;
letter-spacing: 5px;
}
#block1 #subtitle {
font-family: oswald-bold;
font-size: 16pt;
color: white;
letter-spacing: 1px;
}
#block1 a{
width: 184px;
text-align: center;
height: 43px;
line-height: 43px;
border: 1px solid white;
font-family: Oswald-Medium;
font-size: 11pt;
color: white;
text-decoration: none;
font-weight: 100;
display:inline-block;
margin-top:50px;
}
#block1 {
position:absolute;
top:40vh;
left:0;
margin:0 auto;
right:0;
text-align:center;
}
<div id="container">
<div id="block1">
<div id="title">LIAM</div>
<div id="subtitle">SUPER SLIM FIT</div>
See all jeans
</div>
</div>
I am coding this design and i finished it but there is a problem at the final step of my responsive process while trying to scale the boxes in my design to fit the 480px screen and i don't know what to do ?
I tried to give it width and height under #media(min-width: 480px) but i found the width and height in the other media sizes changed !
May you look at this section #media(min-width: 480px) and tell me how to solve this problem and resize the grey box and the green to fit this screen ? Thanks!
here's the code:
body {
background-image: url("../images/bg.png");
margin: 0;
padding: 0;
}
#wrapper {
width: 895px;
height: 493px;
position: relative;
top:-70px;
margin: 0 auto;
}
h1{
margin: auto;
position: relative;
bottom: 300px;
left: 125px;
}
h2{
margin: auto;
position: relative;
bottom: 240px;
left: 540px;
}
.box {
width: 578px;
height: 350px;
margin: auto;
background: -webkit-linear-gradient(280deg, #ffffff, #eeeded); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(280deg, #ffffff, #eeeded); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(280deg, #ffffff, #eeeded); /* For Firefox 3.6 to 15 */
background: linear-gradient(280deg, #ffffff, #eeeded); /* Standard syntax */
position: relative;
top: 150px;
border-radius: 10px 10px 10px 10px;
}
.box2 {
width: 578px;
height: 81px;
margin: auto;
background: #82ba2a;
position: relative;
bottom: 200px;
border-radius: 10px 10px 0 0;
}
.arrow-down {
width: 0;
height: 0;
margin: auto;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-top: 30px solid #82ba2a;
position: relative;
bottom: 200px;
left: 200px;
z-index: 2;
}
.box3{
width: 578px;
height: 6px;
margin: auto;
background: #292929;
position: relative;
bottom: 230px;
z-index: 1;
}
.logo{
margin: auto;
position: relative;
bottom: 60px;
left: 300px;
}
h4{
margin: auto;
font-family: arial;
font-size: 12px;
color: #394256;
position: relative;
bottom: 30px;
}
h5{
margin: auto;
font-family: arial;
font-size: 12px;
color: #394256;
position: relative;
bottom: 25px;
}
button.login {
margin: auto;
width: 124px;
height: 31px;
position: absolute;
bottom: 80px;
left: 585px;
background-color: #2a2a2a;
background: -webkit-gradient(linear, left top, left bottom, from(#747474), to(#2a2a2a));
background: -webkit-linear-gradient(top, #747474, #2a2a2a);
background: -moz-linear-gradient(top, #747474, #2a2a2a);
background: -ms-linear-gradient(top, #6747474, #2a2a2a);
background: -o-linear-gradient(top, #747474, #2a2a2a);
background: linear-gradient(top, #747474, #2a2a2a);
border: 1px solid #2a2a2a;
border-bottom: 1px solid #2a2a2a;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
-o-border-radius: 3px;
color: white;
font-weight: bold;
text-align: center;
text-shadow: 0 -1px 0 #2a2a2a;
}
button.login:hover {
opacity:.85;
cursor: pointer;
}
button.login:active {
border: 1px solid #2a2a2a;
box-shadow: 0 0 10px 5px #2a2a2a inset;
-webkit-box-shadow:0 0 10px 5px #2a2a2a inset ;
-moz-box-shadow: 0 0 10px 5px #2a2a2a inset;
-ms-box-shadow: 0 0 10px 5px #2a2a2a inset;
-o-box-shadow: 0 0 10px 5px #2a2a2a inset;
}
.line{
width: 1px;
height: 180px;
margin: auto;
background: #e4e4e4;
position: absolute;
bottom: 35px;
left: 550px;
}
.contact_form{
text-align: center;
position: absolute;
bottom: 78px;
right: 385px;
border-color: #dbdbdb;
font-family: arial;
font-size: 14px;
font-weight: bold;
}
.contact_form input, .contact_form textarea {
padding-right:70px;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
border:1px solid #dbdbdb;
border-radius:2px;
}
.contact_form input:focus, .contact_form textarea:focus {
background: #ffffff;
border:1px solid #82ba2a;
box-shadow: 0 0 3px #aaa;
}
.shadow {
margin: auto;
position: relative;
bottom: 220px;
left: 70px;
}
/*end*/
/* responsive part */
#media(min-width: 480px) {
.box {
right: 60px;
}
.box2 {
right: 60px;
}
.box3 {
right: 60px;
bottom: 230px;
}
.arrow-down {
left: 140px;
bottom: 200px;
}
.contact_form {
left: 80px;
}
.line {
left: 500px;
}
button.login {
left: 520px;
top: 390px;
}
h4 {
right: 50px;
}
h5 {
right: 50px;
}
}
#media(min-width: 768px) {
.box {
right: 60px;
}
.box2 {
right: 60px;
}
.box3 {
right: 60px;
bottom: 230px;
}
.arrow-down {
left: 140px;
bottom: 200px;
}
.contact_form {
left: 80px;
}
.line {
left: 500px;
}
button.login {
left: 520px;
top: 390px;
}
h4 {
right: 50px;
}
h5 {
right: 50px;
}
}
#media(min-width: 992px) {
.box {
right: 20px;
}
.box2 {
right: 20px;
}
.box3 {
right: 20px;
bottom: 230px;
}
.arrow-down {
left: 180px;
bottom: 200px;
}
.contact_form {
left: 150px;
}
.line {
left: 530px;
}
button.login {
left: 560px;
top: 390px;
}
h4 {
left: -20px;
}
h5 {
left: -20px;
}
h2 {
left: 580px;
}
h1 {
left: 160px;
}
.shadow {
left: 100px;
}
.logo {
left: 339px;
}
}
#media(min-width: 1200px) {
.box {
right: -3px;
}
.box2 {
right: -3px;
}
.box3 {
right: -3px;
bottom: 230px;
}
.arrow-down {
left: 203px;
bottom: 200px;
}
.contact_form {
left: 190px;
}
.line {
left: 553px;
}
button.login {
left: 583px;
top: 390px;
}
h4 {
left: 3px;
}
h5 {
left: 3px;
}
h2 {
left: 603px;
}
h1 {
left: 183px;
}
.shadow {
left: 123px;
}
.logo {
left: 362px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Do Business</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div id=wrapper>
<div class="box"></div>
<div class="box2"></div>
<div class="arrow-down"></div>
<div class="box3"></div>
<h1><img src="images/logo.png" width="199" height="52" /></h1>
<h2><img src="images/key.png" width="92" height="92" /></h2>
<h3 class="logo"><img src="images/logofooter.png" width="178" height="47" /></h3>
<h4><center>2015 COPYRIGHTS, ALL RIGHETS RESERVED FOR DO-BUSINESS SOLUTIONS</center></h4>
<h5>
<p><center>Privacy Policy Terms of Use</center></p>
</h5>
<button class="login" type="submit">LOGIN</button>
<div class="line"></div>
<form class="contact_form" action="" method="post" name="contact_form">
USERNAME <input type="text" name="user">
<br>
<br>
<br>
PASSWORD <input type="password" name="password">
</form>
<div class="shadow"><img src="images/shadow.png" width="657" height="49" /></div>
</div>
</body>
</html>
Best approach would be styling for mobile first, so no media queries is needed only for tablet and larger devices.
But if you want to continue without reshaping the entire site, just use max-width instead of min-width. This way it won't affect the larger resolutions.
Use this media query for mobile only
#media only screen and (min-width : 320px) and (max-width : 480px)
{
//put your styles here
}