I was able to do the Accordion Nav bar to respond on laptop/desktop when a certain size has meant. However, it doesn't respond for any mobile devices. Another issue that I am having is it is not displaying the icon for the Accordion Menu bar for either desktop and mobile devices. Any help would be appreciated to resolve the issue I am having.
Thank you
Responsive CSS:
/*This is the placeholder for responsive CSS that we will implement for mobile design*/
/* Smartphones ----------- */
#media screen and (min-width : 240px) and (max-width: 519px){
/* Styles */
#content{
float:none;
padding:0;
width: auto;
}
img{
max-width: 100%;
height: auto;
width:auto\9; /*for ie8*/
}
body{
float:left;
font-family: 'Fabrica';
}
#logo {
margin-right:auto;
max-width: 100%;
height: auto;
padding: 0;
}
#wrapper{
margin: 0 auto;
}
#wrapper p{
text-indent: 0;
}
h1, h2, h3 {
font-family: 'Fabrica';
}
nav{
position: relative;
min-height: 40px;
}
nav ul{
position:absolute;
width: 180px;
padding: 5px,0;
top: 0;
left: 0;
border: solid 1px #aaa;
background: #fff url(.../img/menu-bar-mobile.jpg) no-repeat 10px 11px;
border-radius: 5px;
box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
nav ul:hover li{
display: block;
margin: 0 0 5px;
}
nav a:hover {
display:block;
}
nav li{
display:none;
margin:none;
}
#banner{
display: none;
}
footer{
font-family: 'Fabrica';
float:left;
}
}
Related
I'm building a website on Github page and I am trying to change color of footer.
As you can see, I made with class "footer" .
On CSS, I put background-color property and set as #000000.
But, I still can't see background color with black on desktop.( I can see on mobile page because I set media query)
The Code is below.
#media screen and (min-width: 1000px) {
html, body{
font-family: "Comfortaa";
}
.header-logo{
float: left;
padding: 10px 30px;
}
.header li:hover{
border-bottom: 2px solid #24ABE2;
}
.header a{
float:left;
display:block;
color:black;
}
.header-link li{
float: left;
padding: 5px 60px;
font-size: 20px;
color:#24ABE2;
}
/* Dropdown Button */
.droplist{
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: white;
min-width: 240px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 20;
margin-top: 29px;
height: 210px;
color:#24ABE2;
}
/* Links inside the dropdown */
.dropdown-content a {
color: #24ABE2;
padding: 12px 16px;
text-decoration: none;
display: block;
z-index: 20;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
border-bottom: 2px solid #24ABE2;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: white;
}
.footer-logo{
float: left;
padding: 15px 20px;
width: 300px;
height: auto;
margin-left: 30px;
margin-top: 20px;
}
.footer-list{
margin-top:10px;
font-size: 20px;
color: #ccfbff;
float: right;
padding: 2px 8px;
margin-right: 40px;
}
.footer-list li{
padding: 10px;
}
}
#media screen and (max-width: 1000px) {
html, body{
font-family: Nunito;
}
.header-logo{
text-align:center;
margin-left:20px;
padding: 10px 30px;
}
.header li{
display:none;
}
.header-link{
display:none;
}
.footer-logo{
padding: 15px 10px;
width: 300px;
height: 90px;
margin:auto;
text-align:center;
}
.footer-logo img{
width: 300px;
height: auto;
margin:auto;
text-align:center;
}
.footer-list{
display:block;
margin:auto;
font-size: 20px;
color: #ccfbff;
padding: 2px 8px;
text-align:center;
}
.footer-list li{
margin:auto;
padding: 5px;
font-size:20px;
text-align:center;
}
}
/* CSS for default design */
html { scroll-behavior: smooth; }
html, body{
height: 100%;
width: 100%;
margin: 0px 0px 0px 0px;
z-index:-10;
}
/* Settings of a tag for whole page*/
a:link {
text-decoration: none;
cursor: pointer;
}
a:visited {
text-decoration: none;
cursor: pointer;
}
a:hover {
text-decoration: none;
cursor: pointer;
}
a:active {
text-decoration: none;
cursor: pointer;
}
.header {
border-bottom:2px solid #0E76BC;
background-color: white;
height: 60px;
position: fixed;
top: 0px;
bottom: 0px;
right: 0px;
left: 0px;
opacity: 90%;
margin: 0px 0px 0px 0px;
z-index:10;
}
.header-logo{
width: 300px;
height: auto;
}
li{
list-style: none;
}
.footer{
height: auto;
background-color: #000000 !important;
width: 100%;
margin: 0px 0px 0px 0px;
}
.footer a:link {
color: #ccfbff;
}
.footer a:visited {
color: #ccfbff;
}
.footer a:hover {
color: #ccfbff;
}
.footer a:active {
color: #ccfbff;
}
<div class="footer">
<img src="https://i.ibb.co/p4LvvdH/Copy-of-LOGO-White.png" alt="SLED Logo" class="footer-logo" />
<div class="footer-list">
<ul>
<li>Back to Top</li>
<li>Instagram</li>
<li>Facebook</li>
<li>Jcbms-sled-team#mail.fcboe.org</li>
<li>J.C. Booth Middle School</li>
<li>Fayette County Public Schools</li>
</ul>
</div>
</div>
Whenever we give float property on child item then parents give automatically own height to 0, so please put it:
.footer:before,
.footer:after
{
clear: both;
display: block;
content: '';
}
The reason is because you set your footer height to auto without defining a minimum height. To solve this just put min-height: 50vh; to your .footer class. Of course you can change 50vh to whatever minimum height you want.
try something like this
.footer
{
min-height: 100%;
background-color: #000000 !important;
width: 100%;
margin: 0px 0px 0px 0px;
}
set min-height: 100% instead of height:auto from .footer class
I have set my header and footer width to 100% but somehow header is wider than page making a scroll bar appear at bottom, content and footer match page width, only header is wider maybe because i have used media query for drop down menu inside header. My code is
* {
margin: 0px;
padding: 0px;
font-family: Arial, Helvetica, Sans-serif;
font-size: 12px;
background-color: #EDEDED;
}
.headerMenu{
width: 100%;
padding: 30px;
background-color:#BF3B3D;
}
#wrapper {
width:100%;
background-color:#BF3B3D;
}
.logo img {
position: absolute;
top:0;
float:left;
background-image: url(../img/menu_bg.gif);
width: 110px;
height: 58px;
}
.search_box {
top: 7px;
float:left;
color: #198C9E;
background-color:#BF3B3D;
position: absolute;
margin-left: 155px;
}
#media screen and (max-width: 1280px) {
.dd {
background-color:#BF3B3D;
position: absolute;
right:0px;
top:0;
margin-right: 4%;
}
}
#media screen and (min-width: 1280px) {
.dd {
background-color:#BF3B3D;
position: absolute;
right:0px;
top:0;
margin-right: 10%;
}
}
#media screen and (min-width: 1920px) {
.dd {
background-color:#BF3B3D;
position: absolute;
right:0px;
top:0;
margin-right: 25%;
}
}
Here dd is class for drop down menu.
That's because you are applying a padding to your header.
To change that behavior, use the box-sizing property.
.headerMenu{
background-color:#BF3B3D;
box-sizing: border-box;
padding: 30px;
width: 100%;
}
I used this code to make my website responsive, but it isn't working. The #media screen part is black and it seems like my browser doesn't recognize this code.
#media screen and(max-width: 478px) {
body {
font-size: 13px;
}
}
#media screen and(max-width: 740px) {
nav{
width: 100%;
margin-bottom: 10px;
}
nav ul{
list-style: none;
margin: 0 auto;
padding-left: 0;
}
nav ul li{
text-align: center;
margin-left: 0 auto;
width: 100%;
border: 1px solid #878E63
}
nav ul li a{
padding: 8px 0px;
font-size: 16px;
}
.left-col{
width: 100%;
}
.sidebar{
width: 100%;
}
.section{
float: left;
width: 100%;
margin: 0px;
}
}
Are you setting the initial scale of your page?:
<meta name="viewport" content="width=device-width, initial-scale=1">
I am using #media to have certain styles for devices. However, it is having issue for tablets and phones. I am currently using a S3 and a hd 7 memo pad tablet to test the responsive aspect of my website. when I am on landscape mode on the S3, the content is not stacked on each other. This feature I would like to have for the tablet but however it does not do it when the tablet is on landscape mode. I would like to know what I am doing wrong. Another issue I am having is the footer. When I am on my tablet, phone, or laptop, there is weird spacing when browser shrinks. I would like to know how to fix the issue. Thank You
/***********************
GENERAL
***********************/
a {
text-decoration: underline;
}
a:hover {
text-decoration: underline;
}
img {
max-width: 100%;
}
body {
/*font-family: 'Fabrica', 'Courier New';*/
font-family: 'Open Sans', sans-serif;
background-color:#e6e9ed;
color: #434a54;
}
#wrapper{
max-width:960px;
margin: 0 auto;
background-color: #f5f7fa;
overflow: auto; /*This fixed the wrapper background color problem that happened bc floating content*/
line-height: 1.8em;
}
#wrapper img {
border-radius:5px 20px 5px;
}
#wrapper p {
text-indent: 2.5em;
}
#banner {
margin-left: auto;
margin-right:auto;
padding: 0;
display:block;
clear:both;
}
#content {
padding:20px 40px;
padding-bottom:50px;
}
h1, h2, h3 {
font-family: 'Droid Serif', serif;
}
.selected {
color:#0B108C;
text-decoration: none;
}
/***********************
HEADER - Top image strip above banner
***********************/
#logo {
text-align:right;
max-height:100%;
max-width:100%;
padding: 10px 0px 10px 30px;
}
#header {
background-image: url(../img/header.jpg);
background-repeat: no-repeat;
background-position: top;
margin: 0 auto;
max-width:960px;
}
/*Commented out for testing new header technique
#header {
margin-left: auto;
margin-right: auto;
padding: 0;
display: block;
clear: both;
font-family: 'Fabrica', Arial;
}
*******/
/***********************
NAVIGATION - Main site navigation
***********************/
nav{
background-color:#4888dc;
text-align:center;
color:blue;
max-width:960px;
margin: 0 auto;
text-align:center;
font-size:1.2em;
}
nav ul{
list-style:none;
margin:0 10px; /*Can be change later on in the design if it doesn't work*/
}
nav li{
/*Inline, mostly text. Appears in the same line, inline as the rest of the text. Block
pushes other items out of the page. Inline block maintains width and
height but is in line with other images*/
display:inline-block;
list-style:none;
padding: .4em 1.5em;
}
nav a {
font-weight: 800;
}
nav a:visited, nav a:link {
color:#f5f7fa;
text-decoration: none;
}
nav a:hover {
color:#0B108C;
text-decoration: none;
}
nav ul li a.selected { /*Highlights current page for users*/
color:#0B108C;
}
/**********************
FOOTER
**********************/
footer {
font-family: 'Open Sans', sans-serif;
max-width:950px;
background-color:#434a54;
font-size:0.75em;
clear:both;
color:#e6e9ed; overflow:auto;
margin: 0 auto;
padding:5px;
}
footer h3{
padding-left: .9em;
font-family: 'Open Sans', sans-serif;
}
footer ul {
display:inline-block;
list-style-type: none;
}
footer ul li{
list-style:none;
text-decoration:none;
margin-left: 1em;
}
footer ul li a{
color:#e6e9ed;
text-decoration:none;
}
footer a:hover {
color:#FFFFFF; /*Change hover color to make it more prominent*/
}
/**********************
RIGHT SIDE OF FOOTER
**********************/
#footer-right {
float:right;
margin-right:15px;
}
.social-icon {
display:inline-block;
width:24px;
height:24px;
margin-bottom:22.7px; /*controls height of "follow us" in footer*/
padding:1px;
border-radius: 20%;
}
/**********************
LEFT SIDE OF FOOTER
**********************/
#footer-left {
float:left;
padding-left: 2em;
text-align:left;
font-size: 1.35em;
display:inline-block;
line-height: 1.5em;
}
#footer-slogan {
font-family: 'Georgia', 'Droid Serif', sans-serif;
}
#copyright{
font-size: .75em;
text-align:left;
margin-top: 5px;
display:inline-block;
font-family: 'Open Sans', sans-serif;
}
/***********************
CONTENT TEMPLATE - Content template for all other pages
***********************/
/*Responsive.css*/
/*This is the placeholder for responsive CSS that we will implement for mobile design*/
/* Smartphones ----------- */
#media screen and (max-width: 519px){
/* Styles */
#content{
float:none;
padding:0;
width: auto;
}
img{
max-width: 100%;
height: auto;
width:auto\9; /*for ie8*/
}
body{
float:left;
font-family: 'Fabrica';
}
#logo {
margin-right:auto;
max-width: 100%;
height: auto;
padding: 0;
}
#wrapper{
margin: 0 auto;
}
#wrapper p{
text-indent: 0;
}
h1, h2, h3 {
font-family: 'Fabrica';
}
nav{
position: relative;
min-height: 40px;
}
nav ul{
position:absolute;
width: 180px;
padding: 5px,0;
top: 0;
left: 0;
border: solid 1px #aaa;
background: #fff url(../img/menu-bar-mobile.jpg) no-repeat 10px 11px;
border-radius: 5px;
box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
nav ul:hover li{
display: block;
margin: 0 0 5px;
}
nav a:hover {
display:block;
}
nav li{
display:none;
margin:none;
}
#banner{
display: none;
}
footer{
font-family: 'Fabrica';
float:left;
}
}
/*Ipads and Tablets*/
#media screen and (min-width:520px) and (max-width: 959px) and (orientation: landscape){
footer{
font-family: 'Fabrica';
float: left;
}
body{
font-family: 'Fabrica';
}
#primary {
width: 55%;
float: left;
padding:10px;
}
#secondary {
width: 30%;
float: right;
padding:10px;
}
}
/* Desktops and laptops ----------- */
#media screen and (min-width: 1200px){
/* Styles */
#primary {
width: 55%;
float: left;
padding:10px;
}
#secondary {
width: 30%;
float: right;
padding:10px;
}
}
/*************************************
TWO COLUMN LAYOUT
Will target anything larger than average smartphone.
This is helpful for normal sized tablets, very large smartphones, and very small desktop windows.
***************************************/
#font-face {
font-family: 'Fabrica';
font-style: normal;
font-weight: 100;
src: local('Fabrica'), local('Fabrica'), url(path/Fabrica.otf) format('otf');
}
Looking at the media query that targets the landscape orientation, the only two elements it mentions (other than the footer), are the ones with id=primary and id=secondary. One of these is floated right, the other floated left, so they won't stack - this will cause them to float to opposite sides of the screen.
In your media query remove the floating and make sure they are both display:block - then they will stack one above the other. (Note: I assume you only have one each of the #primary and #secondary elements, since an id can only be used once on a page).
I'm having a bit of a problem. For some reason a horizontal scroll bar keeps appearing from my code. I've tried everything but I can't seem to remove it. The following link is a live preview of the code.
http://jsfiddle.net/y5x7V/
HTML
<body>
<section class="contain">
<div id="section-nav" class="section-nav">
<div class="top">
<ul>
<li class="logo">Magna Contra</li>
<li class="active">Blog With Us</li>
<li>Compxta</li>
<li>Laurie</li>
<li>SUBTITLESOFLIFE</li>
</ul>
</div>
</div>
</section>
<div class="bg">
<h1>SUBTITLESOFLIFE</h1>
</div>
<ul class="check">
<li class="bold">Hot Trends</li>
<li class="topic">Daft Punk</li>
<li class="topic">#bbcqt</li>
<li class="topic">Petite Noir - Major</li>
<li class="topic">Alt J Album Teaser</li>
<li class="topic">Materialistic Happine$$</li>
<li class="topic">WOLF</li>
</ul>
<div class="contar">
Lorem Dosi
</div>
</body>
</html>
CSS
ul
{
list-style-type:none;
margin:0;
padding:0;
text-align: center;
}
.check{
list-style-type:none;
margin:0;
padding:0;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
display: inline-block;
}
::selection{background:red;color:red;}::-moz-selection{background:red;color:red;}
li
{
display: inline;
padding:15px;
text-align: center;
margin:auto 0;
position: relative;
}
li a{
text-decoration: none;
color:#bbbbbb;
font-family: "proxima-nova",sans-serif;
text-transform: uppercase;
text-align: center;
font-size: 0.78em;
letter-spacing: .2em}
hr{
color:#dfe0db;
border: 0;
background-color: #dfe0db;
height: 1px;
}
.bold{
display: inline;
}
.bold a{
color:#e94378;
}
.topic{
display: inline;
padding:8px;
text-align: center;
margin:auto 0;
position: relative;
}
.topic a{
-webkit-transition:400ms;-moz-transition:400ms;-o-transition:400ms;transition:400ms;color:#bbb;font-weight:700;outline:0;text-decoration:none}
.topic a:hover{
color:#e94378;text-decoration:none}
}
.logo a{
color:#bbb;
font-size: 0.78em;
text-decoration: none;
text-transform: uppercase;
}
img#hv {
filter: url(filters.svg#grayscale); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(1); /* Google Chrome & Safari 6+ */
}
img#hv:hover {
filter: none;
-webkit-filter: grayscale(0);
}
.image {position: relative; text-align: center;width:100%;height:75%;}
.image span {position: absolute; line-height: 20px; display: block; top: 50%;
margin-top: -10px; width: 100%; color: white;font-family: "proxima-nova";
text-transform: uppercase;
font-size: 1.5em; letter-spacing:;}
#media screen and (max-width:800px) {
.image span {
font-size:0.8em;
}
}
#media screen and (max-width:400px) {
.image span {
font-size:0.7em;
}
}
.bg{
background-color: #e94378;
}
img.ri
{
position: relative;
max-width: 100%;
width:100%;
display: inline-block;
vertical-align: middle;
}
#media screen and (orientation: portrait) {
img.ri { max-width: 100%; }
}
#media screen and (orientation: landscape) {
img.ri { max-height: 100%; }
}
.text{
font-family: "proxima-nova";
font-size: 1em;
letter-spacing: .2em;
text-transform: uppercase;
background-color: #e94378;
padding:20px;
color:yellow;
position: absolute;
left:200px;
bottom:50px;
}
.tex{
font-family: "proxima-nova",sans-serif;
font-size: 2.5em;
letter-spacing: 3px;
text-transform: uppercase;
bottom:160px;
left: 320px;
color:white;
padding: 10px;
}
.image{
vertical-align: middle;
}
.logo a:hover{
color:white;
}
.active a{
color:white;
}
.contain{
display: table;
width: 100%;
text-align: center;
margin: 0 auto;
}
.block {
display: table-row;
height: 1px;
}
.navigation {
display: inline-block;
padding: 10px;
width:100%;
margin: auto;
height: 150px;
}
.top {
background-color: #444;
width:100%;
display: inline-block;
padding: 10px;
text-align: center;
}
.navigation:nth-child(odd) {
background: #222;
}
.push {
height: auto;
}
.contar {
margin: 0 auto;
text-align: center;
width:100%;
height:400px;
background-color: white;
}
img.ft{
float:left;
}
.featured{
background-color: white;
width:69%;
text-align: center;
margin: 0 auto;
display: inline-block;;
}
.block:nth-child(odd) {
background: #fff;
}
.search {
border:0px;
background-color:transparent;
color:white;
display: inline-block;
height:28px;
}
.section-nav a{-webkit-transition:400ms;-moz-transition:400ms;-o-transition:400ms;transition:400ms;color:#bbb;font-weight:700;outline:0;text-decoration:none;}
.section-nav a.active,.section-nav a:hover{color:#fff;text-decoration:none}
h1{
font: 800 1em "proxima-nova", sans-serif;
font-size:3.125em;
text-align:center;
padding:10px 10px;
margin:20px 20px;
background-color:;
position: relative;
text-decoration:none;
display:inline-block;
letter-spacing: 6px;
color:yellow;}
h1 a{
text-decoration: none;
letter-spacing: 8px;
padding-left: 0.15em;
color:#a8a820;
}
.txt{
font:800 proxima-nova;
}
h2{
font: 800 1em "proxima-nova", sans-serif;
font-size:3.125em;
text-align:center;
padding:10px 10px;
margin:20px 20px;
background-color:;
position: relative;
text-decoration:none;
display:inline-block;
letter-spacing: 6px;
color:yellow;}
h2 a{
text-decoration: none;
letter-spacing: 8px;
padding-left: 0.15em;
color:#a8a820;
}
Don't use overflow-x: hidden - it only papers over the cracks, it doesn't fix the issue. You can fix it by using the box-sizing property on the top div:
.top {
background-color: #444;
width:100%;
display: inline-block;
padding: 10px;
text-align: center;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
This takes your padding: 10px into account when applying 100% width.
You can also use a polyfill to check for browser support, using the Modernizr plugin.
add
overflow-x:hidden
to the main wrapper class
This is because you're combining both 100% width and padding. If 100% width evaluates to 100px, for example, adding 5px padding to the left and right on top of that will cause your element to have an overall width of 110px. You can get around this by changing the element's box-sizing.
.bottom, .top {
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
}
JSFiddle demo.
You can set overflow-x in body to hidden
http://jsfiddle.net/y5x7V/1/
body {
line-height: 1;
text-align: center;
overflow-x: hidden;
}
You can fix this correctly rather than hacking in some CSS to hide the scrollbar by fixing the top class in your CSS. Set the padding to 0 (as it's taking the full width of the parent) by adding:
padding:0;
to .top
JSFiddle
You can set the padding's height property to get the original look, this is just a quick fix to demo why it's breaking.
Change
.top {padding:10px;}
to
.top {padding:10px 0; }
Line 261 of css you provided, change from padding: 10px;, to padding: 10px 0;.