This is full css of the code. On tablet and on the computer it looks good but not on the mobile device when the website is published. Logo and h1 are not responsive. This is full css of the code. On tablet and on the computer it looks good but not on the mobile device when the website is published. Logo and h1 are not responsive.
body {
margin: 0;
padding: 0;
}
/* header */
.logo-img {
width: 420px;
}
h1 {
text-align: right;
font-family: 'Abel', sans-serif;
font-size: 35px;
margin-top: 20px;
color: #1a1a1a;
text-transform: uppercase;
}
h2 {
text-align: right;
font-family: 'Abel', sans-serif;
font-size: 21px;
color: #1a1a1a;
font-weight: 100;
text-transform: uppercase;
letter-spacing: 6px;
}
.line {
width: 97.5%;
}
/* end header */
/* content */
.main-img {
width: 100%;
}
p {
text-align: center;
margin-top: 10px;
font-family: 'Quicksand', sans-serif;
font-size: 20px;
font-weight: 100;
color: #1a1a1a;
}
.copy {
font-size: 15px;
font-weight: 100;
font-family: 'Quicksand', sans-serif;
}
/* #map {
width: 55%;
height: 200px;
box-sizing: border-box;
text-align: right;
} */
/* end content */
/* footer */
.footer-img {
width: 350px;
margin-right: 15px;
}
h3 {
text-align: center;
font-family: 'Abel', sans-serif;
font-size: 30px;
color: #5d75ab;
text-decoration: none;
margin-top: 10px;
text-transform: uppercase;
}
h4 {
text-align: center;
margin-top: 30px;
text-transform: uppercase;
letter-spacing: 2px;
font-family: 'Abel', sans-serif;
font-size: 24px;
font-weight: 100;
color: #1a1a1a;
}
h5 {
text-align: center;
margin-top: 30px;
font-family: 'Quicksand', sans-serif;
font-size: 20px;
font-weight: 100;
color: #1a1a1a;
}
a href {
text-align: center;
}
a:link {
color: #5d75ab;
text-decoration: none;
}
a:visited {
color: #5d75ab;
text-decoration: none;
}
a:hover {
color: #5d75ab;
text-decoration: none;
color: #1a1a1a;
}
a:active {
color: #5d75ab;
text-decoration: none;
}
.footer-img-container,
.top-row {
margin-top: 30px;
}
.link {
text-align: center;
display: block;
}
/* end footer */
/* Mobile Phone Responsiveness - Nexus 5 */
#media screen and (max-width: 414px) {
h1 {
font-size: 14px !important;
line-height: 80%;
margin-top: 10px;
}
h2 {
font-size: 11px;
letter-spacing: 1.2px;
}
p {
font-size: 12px;
}
h3 {
font-size: 16px;
}
h4 {
font-size: 10px;
}
h5 {
font-size: 11px;
}
.logo-img {
width: 180px;
position: absolute;
}
.main-img {
width: 100%;
}
.footer-img {
width: 100%;
}
.line {
width: 90%;
}
.copy {
font-size: 10px;
font-weight: 100;
font-family: sans-serif;
}
}
/* Tablet Responsiveness - IPad */
#media screen and (min-width:416px) and (max-width: 768px) {
h1 {
font-size: 25px;
margin-top: 0px;
}
h2 {
font-size: 20px;
letter-spacing: 2px;
}
p {
font-size: 16px;
}
h3 {
font-size: 22px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 12px;
}
.logo-img {
width: 250px;
position: absolute;
}
.main-img {
width: 100%;
}
.footer-img {
width: 100%;
}
.line {
width: 95%;
}
.copy {
font-size: 12px;
font-weight: 100;
font-family: sans-serif;
}
}
You can use bootstrap image responsive class.
<img src="images/logo.png" alt="logo" class="img-responsive"/>
And for H1 tag you can use media query to make it responsive font size.
h1 {
font-size: 22px;
}
.img-responsive {
width: 100%;
max-width: 200px
}
#media screen and (max-width: 360px) {
h1 {
font-size: 12px !important;
line-height: 80%;
margin-top: 10px;
}
.img-responsive {
width: 100%;
max-width: 100px
}
}
<img src="https://www.freelancingdesign.com/wp-content/uploads/2015/04/fd-theme-590x300.jpg" alt="logo" class="img-responsive" />
<h1>Logo Goes here</h1>
#media screen and (max-width: 360px) {
h1 {
font-size: 12px !important;
line-height: 80%;
margin-top: 10px;
}
}
Make sure the media query css should be below the main css then it will work, Sequence is matter.
Hope this helpful.
/*Desktop responsive*/
.logo-img {
width: 260px;
}
h1 {
font-size: 58px !important;
line-height: 80%;
margin-top: 10px;
}
/* Mobile Phone Responsiveness */
#media screen and (max-width: 360px) {
h1 {
font-size: 12px !important;
line-height: 80%;
margin-top: 10px;
}
h2 {
font-size: 9px;
letter-spacing: 1.2px;
}
p {
font-size: 12px;
}
h3 {
font-size: 16px;
}
h4 {
font-size: 8px;
}
h5 {
font-size: 11px;
}
.logo-img {
width: 160px;
position: absolute;
}
.main-img {
width: 100%;
}
.footer-img {
width: 100%;
}
.line {
width: 90%;
}
.copy {
font-size: 10px;
font-weight: 100;
font-family: sans-serif;
}
}
<!DOCTYPE html>
<html lang="sh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Abel" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>Frigo MMB</title>
</head>
<body>
<!-- header -->
<div class="container">
<div class="row top-row">
<div class="col-md-6">
<img src="https://www.stickpng.com/assets/images/580b57fcd9996e24bc43c529.png" alt="logo img" class="logo-img">
</div>
<div class="col-md-6">
<h1>Hladjenje & <span style="color: #5d75ab">Klimatizacija</span></h1>
<h2>011.8525636 | 063.7591345</h2>
</div>
</div>
</body>
</html>
May some of the existing code overwriting your h1 tag so i have added !important it will help overwrite the other h1 class.
Hope this snippet will help you.
You can try something like this, if image have width of 400px, then use:
#media screen and (max-width: 400px) {
img {
width: 100%;
}
}
You may need to use different selector for img, same that set the width in your other CSS if you set it.
With header you can put it above the image if it's next to image on desktop.
Related
I want the links email, LinkedIn and GitHub to be responsive by having it directly at the bottom of the title let's connect when in mobile view. Also I would like the margin top of 200px to be none when in mobile view. Apologies for the newbie question.
#media only screen and (max-width: 1200px) {
footer.content-container {
margin-left: 10px;
margin-right: 10px;
}
}
.footer {
grid-area: footer;
margin-top: 38px;
margin-left: 10%;
margin-right: 10%;
height: 700px;
margin-bottom: 100px;
}
.footer-text {
padding: 200px 100px;
font-family: "Khula", sans-serif;
font-weight: 600;
font-size: 80px;
color: #bbbbbb;
line-height: 80px;
letter-spacing: -1px;
display: inline-block;
}
.footer-contact {
font-family: "Khula", sans-serif;
font-weight: 600;
font-size: 35px;
color: #222222;
line-height: 50px;
letter-spacing: -1px;
text-decoration: none;
padding-top: 0px;
margin-left: 60px;
margin-right: 60px;
}
.footer-text-color {
color: #222222;
}
ul {
list-style-type: none;
text-decoration: none;
margin-top: 200px;
float: right;
}
<footer class="content-container footer">
<div class="footer-text">Let's <br> <span class="footer-text-color">Connect</span></div>
<ul>
<li>Email</li>
<li>LinkedIn</li>
<li>GitHub</li>
</ul>
</footer>
add this to your css:
#media only screen and (max-width: 845px) {
.footer-text {
padding-bottom: 0;
}
ul {
margin-top: 0;
float: unset;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
#media only screen and (max-width: 1200px) {
footer.content-container {
margin-left: 10px;
margin-right: 10px;
}
}
.footer {
grid-area: footer;
margin-top: 38px;
margin-left: 10%;
margin-right: 10%;
height: 700px;
margin-bottom: 100px;
}
.footer-text {
padding: 200px 100px;
font-family: "Khula", sans-serif;
font-weight: 600;
font-size: 80px;
color: #bbbbbb;
line-height: 80px;
letter-spacing: -1px;
display: inline-block;
}
.footer-contact {
font-family: "Khula", sans-serif;
font-weight: 600;
font-size: 35px;
color: #222222;
line-height: 50px;
letter-spacing: -1px;
text-decoration: none;
padding-top: 0px;
margin-left: 60px;
margin-right: 60px;
}
.footer-text-color {
color: #222222;
}
ul {
list-style-type: none;
text-decoration: none;
margin-top: 200px;
float: right;
}
#media only screen and (max-width: 845px) {
.footer-text {
padding-bottom: 0;
}
ul {
margin-top: 0;
float: unset;
}
}
</style>
</head>
<body>
<footer class="content-container footer">
<div class="footer-text">
Let's <br />
<span class="footer-text-color">Connect</span>
</div>
<ul>
<li>Email</li>
<li>LinkedIn</li>
<li>GitHub</li>
</ul>
</footer>
</body>
</html>
I have been trying to use a static image on my website, but there is a large gap between the header and the image, I've tried removing padding and changing the image height in Photoshop and in HTML.
Here's a fiddle of my problem https://jsfiddle.net/o27w80ve/
section.module:last-child {
margin-bottom: 0;
}
section.module h2 {
font-family: "Roboto Slab", serif;
font-size: 30px;
}
section.module p {
margin-bottom: 40px;
font-size: 16px;
font-weight: 300;
}
section.module p:last-child {
margin-bottom: 0;
}
section.module.content {
padding: 40px 0;
color: #090C02;
}
section.module.content#section1 {
background-color: #b23783;
}
section.module.content#section2 {
background-color: #3783b2;
}
section.module.parallax {
height: 600px;
background-position: 50% 50%;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
section.module.parallax h1 {
color: #8FD5A6;
font-size: 48px;
line-height: 600px;
font-weight: 700;
text-align: center;
text-transform: uppercase;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
font-family: 'Julius Sans One', sans-serif;
}
section.module.parallax-1 {
background-image: url("https://i.imgur.com/YpRAOt3.jpg");
}
#media all and (min-width: 600px) {
section.module h2 {
font-size: 42px;
}
section.module p {
font-size: 20px;
}
section.module.parallax h1 {
font-size: 96px;
}
}
#media all and (min-width: 960px) {
section.module.parallax h1 {
font-size: 160px;
}
}
.header ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #1e1e20;
}
.header li {
float: right;
text-align: middle;
}
.header li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-family: 'Bitter', serif;
}
.header li:hover {
background-color: #fec10e;
color: black;
}
<header class="header">
<div>
<ul>
<li>Testr Co.</li>
<li>Home</li>
<li>About Us</li>
<li>Blog</li>
</ul>
</div>
</header>
<section class="module parallax parallax-1">
<div class="container">
<h1>Example</h1>
</div>
</section>
That's called "margin collapse." The defaut margin-top on the h1 is collapsing outside of the parent.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
Parent and first/last child - If there is no border, padding, inline content, block_formatting_context created or clearance to separate the margin-top of a block from the margin-top of its first child block, or no border, padding, inline content, height, min-height, or max-height to separate the margin-bottom of a block from the margin-bottom of its last child, then those margins collapse. The collapsed margin ends up outside the parent.
section.module:last-child {
margin-bottom: 0;
}
section.module h2 {
font-family: "Roboto Slab", serif;
font-size: 30px;
}
section.module p {
margin-bottom: 40px;
font-size: 16px;
font-weight: 300;
}
section.module p:last-child {
margin-bottom: 0;
}
section.module.content {
padding: 40px 0;
color: #090C02;
}
section.module.content#section1 {
background-color: #b23783;
}
section.module.content#section2 {
background-color: #3783b2;
}
section.module.parallax {
height: 600px;
background-position: 50% 50%;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
section.module.parallax h1 {
color: #8FD5A6;
font-size: 48px;
line-height: 600px;
font-weight: 700;
text-align: center;
text-transform: uppercase;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
font-family: 'Julius Sans One', sans-serif;
margin-top: 0;
}
section.module.parallax-1 {
background-image: url("https://i.imgur.com/YpRAOt3.jpg");
}
#media all and (min-width: 600px) {
section.module h2 {
font-size: 42px;
}
section.module p {
font-size: 20px;
}
section.module.parallax h1 {
font-size: 96px;
}
}
#media all and (min-width: 960px) {
section.module.parallax h1 {
font-size: 160px;
}
}
.header ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #1e1e20;
}
.header li {
float: right;
text-align: middle;
}
.header li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-family: 'Bitter', serif;
}
.header li:hover {
background-color: #fec10e;
color: black;
}
<header class="header">
<div>
<ul>
<li>Testr Co.</li>
<li>Home</li>
<li>About Us</li>
<li>Blog</li>
</ul>
</div>
</header>
<section class="module parallax parallax-1">
<div class="container">
<h1>Example</h1>
</div>
</section>
After inspecting your code you can notice that the 'section.module.parallax h1' has a margin-top of 40px.
You need to use this (margin-top:0) to remove the gap.
I have been fighting with a jumbotron background image which I managed to properly line up on the website but I can't seem to make it be mobile responsive. The link for the site is puremistdiffusers.com
Here is the HTML:
<div class="jumbotron" style="background-image: url(https://puremistdiffusers.com/wp-content/uploads/2017/02/slider-candle-jpeg-dark.jpg); background-repeat: no-repeat;">
<div class="container">
<h1 class="text-uppercase">YOUR AROMATHERAPY</h1>
<p>UP TO 40% OFF ON ALL PRODUCTS</p>
<a class="btn btn-default btn-inverse btn-lg text-uppercase topbutton" href="https://puremistdiffusers.com/product/" role="button">Shop Now</a>
</div>
</div>
and here is the CSS:
}
.jumbotron {
background-color: #fff !important;
}
.jumbotron {
padding-top: 48px;
padding-bottom: 48px;
height: 397px !important;
background-position: center;
width: 100%;
}
.jumbotron .container {
max-width: 100%;
}
.jumbotron h1, .jumbotron .h1 {
color: #fff;
font-size: 50px !important;
text-align: center;
}
.jumbotron h1, .jumbotron .h1 {
color: #fff;
font-family: "Adobe Garamond Pro", "Adobe Caslon Pro", Helvetica, Arial, sans-serif;
font-size: 1.5rem;
}
.jumbotron p {
margin-bottom: 15px;
font-size: 30px;
font-weight: 400;
color: #fff;
text-align: center;
}
.btn-default.btn-inverse {
color: #FFFFFF;
background-color: #162e00;
border-color: #FFFFFF;
}
.topbutton {
padding: 1% 6%;
font-size: 20px;
line-height: 2.375rem;
border-radius: 0.1875rem;
margin-left: 38%;
margin-top: 3%;
}
.btn:hover{
background:transparent;
color:#fff;
}
#media (max-width:768px){
.jumbotron h1, .jumbotron .h1 {
color: #fff;
font-size: 30px !important;
}
.jumbotron p {
font-size: 17px;
}
.jumbotron {
height: 259px !important;
}
.btn {
margin-left: 30%;
}
}
#media (max-width:640px){
.jumbotron h1, .jumbotron .h1 {
color: #fff;
font-size: 20px !important;
}
.jumbotron p {
font-size: 12px;
}
.jumbotron {
height: 259px !important;
}
.btn {
margin-left: 30%;
}
}
#media (max-width:480px){
.jumbotron h1, .jumbotron .h1 {
color: #fff;
font-size: 17px !important;
}
.jumbotron p {
font-size: 12px;
}
.jumbotron {
height: 259px !important;
}
.btn {
margin-left: 30%;
}
}
I tried several different techniques that I found here on stackoverflow but I would either get everything to line up on the left and not be centred or centre everything but loose the mobile responsiveness. Thanks in advance.
Ok , to add this lines :
.jumbotron {
background-image: url('your image background');
height: 100%;
width: 100%;
background-size: cover;
}
.jumbotron .container {
position: relative;
top:100px;
}
and in your head tag in html add this :
<meta name="viewport" content="width=device-width, initial-scale=1">
I'm using this css code for mobile device. In chrome it looks ok, but in FireFox this code isn't running, so my website doesn't change. What should i do?
#media (min-width: 220px) and (max-width: 480px) {
.nav a {
color: #5a5a5a;
font-size: 14px;
padding: 14px 10px;
font-family: 'Open Sans', sans-serif;
}
.nav ul.pull-left{
padding-top: 5px;
padding-left: 80px;
}
.nav ul.pull-right{
padding-top: 30px;
}
.nav li {
display: inline;
padding-bottom: 5px;
}
.nav-account{
background-color: #204056;
}
.nav-account a {
color: #fff;
font-size: 13px;
padding: 14px 10px;
font-family: 'Open Sans', sans-serif;
}
.nav-account ul.pull-right{
padding-top: 10px;
}
.nav-account li {
display: inline;
padding-bottom: 10px;
}
.site-header {
width: 100%;
height: 100%;
min-height: 50vh;
position: relative;
text-align: center;
background: url(../images/novotel.jpg) no-repeat center center/cover;;
}
}
I think you need to add the media type after "#media".
Try #media all and (min-width: 220px) and (max-width: 480px) {
...
}
HTML
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Coming Soon</title>
<link href="css/Main.css" rel="stylesheet">
</head>
<body>
<section class="content">
<div style="width:500px;
margin:0 auto;
top:25%;
position:relative">
<img src="img/logo.png">
<img src="img/line.png">
<p class="header large-2 white padding-top-triple">Coming This Fall 2015</p>
<p class="white padding-top"><span class="header">Email: </span>
<a href="mailto:Jethwa96#hotmail.co.uk">
<my-email data-user="Jethwa" data-domain="jedesigns.uk"></my-email>
</a>
</p>
</div>
</section>
</body>
</html>
CSS
/* Typography */
.header {
font-family: "futura-pt", Arial, Helvetica, sans-serif;
font-weight: 700;
font-size: 1.0em;
margin: 0;
padding: 0;
text-transform: uppercase;
letter-spacing: 0.1em;
}
p {
font-family: "futura-pt", Arial, Helvetica, sans-serif;
font-weight: 400;
font-size: 1.0em;
margin: 0;
padding: 0;
text-transform: uppercase;
letter-spacing: 0.1em;
}
/* Sizes */
.large-5 {
font-size: 5.0em;
}
.large-4 {
font-size: 4.0em;
}
.large-3 {
font-size: 3.0em;
}
.large-25 {
font-size: 2.5em;
}
.large-2 {
font-size: 1.5em;
}
.large-15 {
font-size: 1.3em;
}
#media screen and (min-width: 768px) {
.large-5 {
font-size: 5.0em;
}
.large-4 {
font-size: 4.0em;
}
.large-3 {
font-size: 3.0em;
}
.large-25 {
font-size: 2.5em;
}
.large-2 {
font-size: 2.0em;
}
.large-15 {
font-size: 1.5em;
}
}
/* Colours */
.white {
color: #fff;
}
.black {
color: #000;
}
/* Spacing */
.padding-top {
padding-top: 2em;
}
.padding-top-double {
padding-top: 2em;
}
.padding-top-triple {
padding-top: 1em;
}
.padding-bottom {
padding-bottom: 1em;
}
/* Links */
a:link,
a:visited,
a:active {
color: #fff;
text-decoration: none;
}
a:hover {
color: #fff;
text-decoration: underline;
}
/* General */
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
text-align: center;
background: #fff;
}
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* Structure */
.content {
width: 100%;
position: relative;
height: 1200px;
margin: 0 auto;
border: 3px solid #fff;
background: url(http://jedesigns.uk/img/hd-sunset-river-HD-1200x1920.jpg) no-repeat;
}
.content img {
max-width: 100%;
}
my-email::after {
content: attr(data-domain);
}
my-email::before {
content: attr(data-user)"\0040";
}
I need to know how to fit the background image fully on any screen device so its responsive to any device.
i have tried many ways but it didn't worked so hopefully the people of stack overflow can help :)
You need to use background-size:coverbut propely. That means give 100% height to your .content(and add it to all the parents including html) basically:
html, section {height:100%;}
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
text-align: center;
background: #fff;
}
*, *:before, *:after {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
/* Structure */
.content{
width: 100%;
position: relative;
height: 100%;
margin: 0 auto;
border: 3px solid #fff;
background:url(http://jedesigns.uk/img/hd-sunset-river-HD-1200x1920.jpg) no-repeat;
background-size:cover;
background-position:center, bottom;
}
.content img {
/* max-width: 100%;*/
}
and I also removed the styles you add inline. .content img is wrong css as you don't have any <img>in the html to call.
JSFIDDLE