I am trying to center my logo and search bar within my blue header. In my site I am using a section with a width of 1200px and inside the header there is also a "headersection" that is 1200px. I want the logo on the left side of this section and the searchbar in the middle. How can I accomplish this?
Live codepen: https://codepen.io/PHV/pen/dyvXGaa
My HTML:
<div class="usp-banner" role="complementary">
<ul class="uspBannerList">
<li class="uspBannerList">Vind de leukste en goedkoopste bordspellen op Spelplaats.com</li>
<li class="uspBannerList">Vergelijk prijzen bij verschillende aanbieders</li>
</ul>
</div>
<div class="header">
<div class="headersection">
<div class="logo">
<img src="img/Spelplaats-Logo-F.png" alt="Spelplaats.com" class="logo">
</div>
<script src="js/searchfunction.js"></script>
<div class="search">
<form action="search.html" method="get">
<label for="search" class="search"></label>
<input type="text" class="searchTerm" placeholder="Zoek spel" name="search">
</form>
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</div>
</div>
</div>
</div>
<div class="topnav" id="myTopnav">
Strategie
Fantasy
Deductieve
Cooperatief
Familie
Kinder
Kaartspellen
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
My CSS:
html {
color: #ffffff;
font-size: 1em;
line-height: 1.4;
-webkit-font-smoothing: antialiased;
}
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,600,700,800);
/* No padding on the site*/
*,html,body,div,dl,dt,dd,ul,ol,li,h2,h3,h5,h6,pre,form,label,fieldset,input,blockquote,th,td {
margin: 0;
padding: 0;
}
article,aside,figure,footer,header,hgroup,nav,section {
display: block;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* Site background */
body {
background: #ffffff;
color: #374147;
font: 14px "Open Sans",Helvetica,Arial,sans-serif;
-webkit-font-smoothing: antialiased;
line-height: 1.4;
margin: auto;
}
h2{
font: 16px "Open Sans",Helvetica,Arial,sans-serif;
font-weight: bold;
margin-top: 3px;
margin-bottom: 5px;
}
h3 {
font: 14px "Open Sans",Helvetica,Arial,sans-serif;
font-weight: bold;
margin-top: 3px;
}
/* Add a black background color to the top navigation */
.topnav {
background-color: #eff7fa;
overflow: hidden;
text-align: center;
}
/* Style the links inside the navigation bar */
.topnav a {
display: inline-block;
color: #374147;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
/* Add an active class to highlight the current page */
.topnav a.active {
background-color: rgb(0, 51, 109);
color: white;
}
.topnav input[type=text] {
float: right;
padding: 6px;
margin-top: 8px;
margin-right: 16px;
border: none;
font-size: 17px;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
/* Styling of the section */
section{
max-width: 1200px;
min-height: 1000px;
margin-left: auto;
margin-right: auto;
}
.headersection{
max-width: 1200px;
max-height: 96px;
margin-left: auto;
margin-right: auto;
}
/* Styling of complementary banner */
.usp-banner {
display: block;
max-width: 900px;
margin-left: auto;
margin-right: auto;
padding: 3px;
font: 14px "Open Sans",Helvetica,Arial,sans-serif;
line-height: 1.5rem;
color: #374147;
background: #fff;
height: 30px;
}
#media screen and (max-width: 600px) {
.usp-banner{
display: none;
}
}
#media screen and (max-width: 768px) {
.usp-banner{
display: none;
}
}
.uspBannerList ul{
margin-left: 0;
padding-left: 0;
}
.uspBannerList li{
list-style-type: none;
margin-right: 2.5%;
margin-left: 2.5%;
width: 45%;
float: left;
height: auto;
}
/*Styling of searchbar */
.search {
width: 35%;
position: relative;
display: flex;
left: 12%;
margin: auto;
}
#media screen and (max-width: 600px) {
.search{
width: 50%;
}
}
#media screen and (max-width: 768px) {
.search{
width: 60%;
}
}
.searchTerm {
width: 300px;
border: 3px solid #fff;
border-right: none;
padding: 5px;
height: 36px;
border-radius: 5px 0 0 5px;
outline: none;
color: #374147;
}
#media screen and (max-width: 600px) {
.searchTerm{
width: 100px;
}
}
.searchTerm:focus{
color: #374147;
}
.searchButton {
width: 40px;
height: 36px;
border: 1px solid #fff;
background: #57bdfc;
text-align: center;
color: #fff;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
/*Styling of the header */
.header {
padding: 35px;
text-align: center;
background: #57bdfc;
color: white;
}
.logo {
height: 96px;
float: left;
position: relative;
}
#media screen and (max-width: 600px) {
.logo{
margin-left: 5px;
}
}
#media screen and (max-width: 768px) {
.logo{
margin-left: 5px;
}
}
Update these css
.headersection {
max-width: 1200px;
max-height: 96px;
margin-left: auto;
margin-right: auto;
display: flex;
justify-content: space-between;
align-items: center;
}
.search {
display: flex;
}
if you want to have padding for the header and the height of .headersection be limit
you should set position absolute for .logo as below:
.logo { position: absolute; top: 0; bottom: 0; margin: auto}
and set position relative for .header.
but this is not good practice.
you can easily use this code for better result :
.header {
display: flex;
align-items: center;
}
remove .headersection because there is no need
this might be helpful
.logo {
height: 96px;
float: left;
position: relative;
margin-top: -15px; <--- adjust according to your need..
}
Related
right now the purple just covers the text but it should be a nice block of colour like the dropdown is. Also, I have a bar under my nav img that should not be there when I hover. I know it is a width/height thing, but no matter where I put the code it does not work.
https://codepen.io/Smoki248/pen/NWxrOWK
li {
list-style: none;
}
a {
color: #f2f2f2;
text-decoration: none;
}
a:hover {
background-color: #8781bd;
}
.container {
max-width: 100%;
width: 100%;
margin: 0 auto;
text-align: center;
}
.btn {
padding: 0 20px;
height: 40px;
font-size: 1em;
font-weight: 400;
font-family: "Amatic SC", Roboto, sans-serif;
border: 1px #8781bd solid;
border-radius: 2px;
background: #8781bd;
color: #f2f2f2;
cursor: pointer;
}
.grid {
display: flex;
}
header {
position: fixed;
top: 0;
min-height: 75px;
padding: 0px 0px;
display: flex;
align-items: center;
background-color: #2f2f2f;
}
#media (max-width: 600px) {
header {
flex-wrap: wrap;
}
}
.logo {
width: 60vw;
}
#media (max-width:650px) {
.logo {
margin-top: 15px;
width: 100%;
position: relative;
}
}
.logo > img {
width: 100%;
height: 100%;
max-width: 100px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin-left: 20px;
}
#media (max-width: 650px) {
.logo > img {
margin: 0 auto;
}
}
nav {
font-weight: 400;
}
#media (max-width: 650px) {
nav {
margin-top: 10px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 0 50px;
}
}
h1 {
font-family: "Amatic SC", Raleway, Roboto, sans-serif;
font-size: 35pt;
width: 100%;
text-align: center;
}
h2 {
font-family: "Amatic SC", Raleway, Roboto, sans-serif;
font-size: 24pt;
width: 100%;
text-align: center;
}
nav li {
padding-bottom: 30px 0px;
}
nav > ul {
width: 30vw;
display: flex;
flex-direction: row;
justify-content: space-around;
}
#media (max-width: 650px) {
nav > ul {
flex-direction: column;
}
}
.dropdown > li{
float: right;
overflow: hidden;
}
.dropdown > li a {
font-size: 16px;
border: none;
outline: none;
color: #f4f4f4;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: 0;
}
nav > li a:hover, .dropdown:hover a {
background-color: #8781bd;
color:#f4f4f4;
}
.dropdown-content {
display: none;
position: absolute;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
color: #f4f4f4;
z-index: 1;
margin-top: 20px;
min-width: 100px;
}
.dropdown-content li a {
float: none;
color: #f4f4f4;
padding: 10px 14px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content li a:hover {
background-color: #625aa9;
color: #f4f4f4;
}
.dropdown:hover .dropdown-content {
display: block;
}
<header id="page-wrapper">
<header id="header">
<div class="logo">
<nav>
<a href="http://www.wrecklessdevelopment.com"><img id="header-img"
src="images/wreckless-development-logo.gif" alt="Wreckless Development Logo"/></a>
</nav>
</div>
<h1>Wreckless Development</h1>
<nav id="navbar">
<ul>
<li>About</li>
<li>Services</li>
<div class="dropdown">
<li><i class="fa fa-caret-down"></i> Portfolio<li>
<div class="dropdown-content">
<ul>
<li>Photography</li>
<li>Composite</li>
<li>Logos</li>
<li>Branding</li>
<li>Advertising</li>
</ul>
</div>
</div>
<li>Contact</li>
<li>Blog</li>
</ul>
</nav>
</header>
</header>
The problem is tag a's default display is inline, so if you want to adjust height of a tag, you have to change it's default display to display: inline-block like this, and then you may be able to do whatever you want with that a tag, you can refer my code below for more details:
#header a {
display: inline-block; // change display style
height: 75px;
line-height: 75px; // center the text
padding-left: 12px;
padding-right: 12px;
}
.dropdown > li > a {
padding: 0 16px; // no need to padding top and bottom because we already had line-height and height
}
.dropdown-content{
margin-top: 75px; // push the .dropdown-content further to fit new css
}
#header .dropdown-content li a{
display: block; // set an <a> tag to full with of the dropdown
height: auto;
line-height: 16px; // center the text with current font-size
}
you can take a look in my codepen.io for more details here. Hope it will help
there is full code of my plugin > https://codepen.io/doodlemarks/pen/aFcly
in my code element #slider ul li have width bigger than 900px and it is not scaling smaller on device with smaller resolution.
can anyone help me how to improve it and make it responsible to scale ul li element on devices e.g. mobile?
html/css:
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600);
html {
border-top: 5px solid #fff;
background: #58DDAF;
color: #2a2a2a;
}
html, body {
margin: 0;
padding: 0;
font-family: 'Open Sans';
}
h1 {
color: #fff;
text-align: center;
font-weight: 300;
}
#slider {
position: relative;
overflow: hidden;
margin: 20px auto 0 auto;
border-radius: 4px;
}
#slider ul {
position: relative;
margin: 0;
padding: 0;
height: 200px;
list-style: none;
}
#slider ul li {
position: relative;
display: block;
float: left;
margin: 0;
padding: 0;
width: 500px;
height: 300px;
background: #ccc;
text-align: center;
line-height: 300px;
}
a.control_prev, a.control_next {
position: absolute;
top: 40%;
z-index: 999;
display: block;
padding: 4% 3%;
width: auto;
height: auto;
background: #2a2a2a;
color: #fff;
text-decoration: none;
font-weight: 600;
font-size: 18px;
opacity: 0.8;
cursor: pointer;
}
a.control_prev:hover, a.control_next:hover {
opacity: 1;
-webkit-transition: all 0.2s ease;
}
a.control_prev {
border-radius: 0 2px 2px 0;
}
a.control_next {
right: 0;
border-radius: 2px 0 0 2px;
}
.slider_option {
position: relative;
margin: 10px auto;
width: 160px;
font-size: 18px;
}
<h1>Incredibly Basic Slider</h1>
<div id="slider">
>
<
<ul>
<li>SLIDE 1</li>
<li style="background: #aaa;">SLIDE 2</li>
<li>SLIDE 3</li>
<li style="background: #aaa;">SLIDE 4</li>
</ul>
</div>
<div class="slider_option">
<input type="checkbox" id="checkbox">
<label for="checkbox">Autoplay Slider</label>
</div>
You can use #media CSS at-rule in your code just for example
<style>
/* First Example */
/* For desktop: */
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
#media only screen and (max-width: 768px) {
/* For mobile phones: */
[class*="col-"] {
width: 100%;
}
}
/* Second Example */
#media screen and (min-width: 900px) {
article {
padding: 1rem 3rem;
}
}
</style>
You can learn more about responsive web by these links
https://www.w3schools.com/css/css_rwd_intro.asp
https://developer.mozilla.org/en-US/docs/Web/CSS/#media
I have had issues with modify a navigation bar for mobile. I want the navigation bar to ignore its parent div inner-wrapper width of 80% and use a full width of 100%.
The most logical solution I can think of is to set header: relative, width: 100% and header li to absolute with a width of 100%. However, this doesn't seem to work.
I want each navigation to have a full width of the screen rather than a full width of its parent wrapper.
.header {
background-color: #FFB6C1;
color: black;
overflow: hidden;
position: relative;
}
.inner-wrapper {
width: 80%;
margin: 0 auto;
margin-top: 30px;
margin-bottom: 20px;
}
.header h2 {
float: left;
font-family: 'Pacifico', sans-serif;
font-size: 30px;
}
.header h3 {
padding-top: 5px;
font-family: 'Petit Formal Script';
clear: both;
font-weight: 700;
}
.header span {
font-weight: bolder;
}
.header ul {
float: right;
margin-right: 10%
}
.header ul li {
list-style: none;
display: inline-block;
font-family: 'Podkova', sans-serif;
margin-right: 20px;
font-weight: bold;
}
/* Navigation Menu click for mobile */
.mobile-menu {
padding: 0;
margin: 0;
display: none;
}
/* Smartphones (portrait) ----------- */
#media only screen and (max-width: 414px) {
/* Styles */
/* Display flex to change the ordering of HTML elemtns*/
.inner-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 0px;
}
.header-title {
order: 1;
}
.header-description {
order: 2;
}
.dropdown {
order: 3;
}
.header-li {
display: none;
position: absolute;
width: 100%;
}
.header ul {
float: none;
margin-right: 0%;
}
.mobile-menu {
padding: 0;
margin: 0;
display: initial;
cursor: pointer;
}
.header ul li {
width: 100%;
background-color: green;
padding-top: 20px;
}
.header {
position: relative;
width: 100%;
}
}
<!-- Header and Navigation -->
<div class="header">
<div class="inner-wrapper">
<h2 class="header-title">text</h2>
<div class="dropdown">
<div class="mobile-menu">
<p align="right">Menu</p>
</div>
<ul class="header-li">
<li>About me</li>
<li>Progress</li>
<li>Food</li>
<li>Contact</li>
</ul>
</div>
<h3 class="header-description">text</span></h3>
</div>
</div>
If you want the navigation to have full width of the screen use width: 100vw; on the child. That means 100% of the view width
Using viewport units seems initially like a good idea, though in this case it is not necessary and will be of no use as the header uses overflow: hidden.
Note, if you start using 100vw it can cause unwanted scrollbar and/or make the element behave in an unwanted way when its parent/body has scrollbar
As the header-li relates to the header (closest ancestor having a position other than static), simply use 100% and transform: translate to position it.
.header-li {
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 100%;
background: lime;
}
Note, it below sample I colored it light gray so one see how it positions itself
Stack snippet
.header {
background-color: #FFB6C1;
color: black;
overflow: hidden;
position: relative;
}
.inner-wrapper {
width: 80%;
margin: 0 auto;
margin-top: 30px;
margin-bottom: 20px;
}
.header h2 {
float: left;
font-family: 'Pacifico', sans-serif;
font-size: 30px;
}
.header h3 {
padding-top: 5px;
font-family: 'Petit Formal Script';
clear: both;
font-weight: 700;
}
.header span {
font-weight: bolder;
}
.header ul {
float: right;
margin-right: 10%
}
.header ul li {
list-style: none;
display: inline-block;
font-family: 'Podkova', sans-serif;
margin-right: 20px;
font-weight: bold;
}
.header-li {
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 100%;
background: lightgray;
}
/* Navigation Menu click for mobile */
.mobile-menu {
padding: 0;
margin: 0;
display: none;
}
/* Smartphones (portrait) ----------- */
#media only screen and (max-width: 414px) {
/* Styles */
/* Display flex to change the ordering of HTML elemtns*/
.inner-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 0px;
}
.header-title {
order: 1;
}
.header-description {
order: 2;
}
.dropdown {
order: 3;
}
.header-li {
display: none;
position: absolute;
width: 100%;
}
.header ul {
float: none;
margin-right: 0%;
}
.mobile-menu {
padding: 0;
margin: 0;
display: initial;
cursor: pointer;
}
.header ul li {
width: 100%;
background-color: green;
padding-top: 20px;
}
.header {
position: relative;
width: 100%;
}
}
<!-- Header and Navigation -->
<div class="header">
<div class="inner-wrapper">
<h2 class="header-title">text</h2>
<div class="dropdown">
<div class="mobile-menu">
<p align="right">Menu</p>
</div>
<ul class="header-li">
<li>About me</li>
<li>Progress</li>
<li>Food</li>
<li>Contact</li>
</ul>
</div>
<h3 class="header-description"><span>text</span></h3>
</div>
</div>
If you want the header-li to expand beyond the header as well, you will need to both remove overflow: hidden, use 100vw and remove the padding the ul has as a default (or else you'll get a scroll)
.header {
background-color: #FFB6C1;
color: black;
position: relative;
}
.inner-wrapper {
width: 80%;
margin: 0 auto;
margin-top: 30px;
margin-bottom: 20px;
}
.header h2 {
float: left;
font-family: 'Pacifico', sans-serif;
font-size: 30px;
}
.header h3 {
padding-top: 5px;
font-family: 'Petit Formal Script';
clear: both;
font-weight: 700;
}
.header span {
font-weight: bolder;
}
.header ul {
float: right;
margin-right: 10%
}
.header ul li {
list-style: none;
display: inline-block;
font-family: 'Podkova', sans-serif;
margin-right: 20px;
font-weight: bold;
}
.header-li {
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 100vw;
background: lightgray;
padding: 0;
}
/* Navigation Menu click for mobile */
.mobile-menu {
padding: 0;
margin: 0;
display: none;
}
/* Smartphones (portrait) ----------- */
#media only screen and (max-width: 414px) {
/* Styles */
/* Display flex to change the ordering of HTML elemtns*/
.inner-wrapper {
display: flex;
flex-direction: column;
margin-bottom: 0px;
}
.header-title {
order: 1;
}
.header-description {
order: 2;
}
.dropdown {
order: 3;
}
.header-li {
display: none;
position: absolute;
width: 100%;
}
.header ul {
float: none;
margin-right: 0%;
}
.mobile-menu {
padding: 0;
margin: 0;
display: initial;
cursor: pointer;
}
.header ul li {
width: 100%;
background-color: green;
padding-top: 20px;
}
.header {
position: relative;
width: 100%;
}
}
<!-- Header and Navigation -->
<div class="header">
<div class="inner-wrapper">
<h2 class="header-title">text</h2>
<div class="dropdown">
<div class="mobile-menu">
<p align="right">Menu</p>
</div>
<ul class="header-li">
<li>About me</li>
<li>Progress</li>
<li>Food</li>
<li>Contact</li>
</ul>
</div>
<h3 class="header-description"><span>text</span></h3>
</div>
</div>
How's this James?
.theContainer {
width: 200px;
height: 200px;
background-color: gray;
position: relative;
}
.theParent {
width: 80%;
height: 150px;
background-color: lightgray;
}
.theChild {
width: 100%;
background-color: lightgreen;
position: absolute;
}
<div class="theContainer">
<div class="theParent">
This is the parent trying to restrict the child to 80% width.
<div class="theChild">
This is the child with 100% width ignoring parent.
</div>
</div>
</div>
I'm in the midst of creating a responsive portfolio at the moment and I'm running into a bit of trouble.
Before a certain breakpoint (css media query), the second and third paragraph in the 'About' section of my website are in floats. As the window gets smaller, the text starts to overlap the footer and eventually create a whitespace at the bottom and side. When it reaches the breakpoint, the floats are valued as 'none'.
How can I make it so that the height of the container is determined by how much content is in there (i.e. the normal behaviour)? I've tried a clearfix, but that doesn't seem to work.
https://codepen.io/webdevkid/pen/gmBVMj
HTML
<body>
<nav>
<div id="logo"><a id="logo-link" href="index.html"><span id="word-1">Potential </span><span id="word-2">Beginning</span></a><div id="menu-icon"></div></div><div class="clear"></div>
<ul id="main-links">
<li><span class="word-position">About</span></li>
<li><span class="word-position">Work</span></li>
<li class="last-child"><span class="word-position">Contact</span></li>
</ul>
</nav>
<div id="main-container">
<div id="introductory-background">
<div id="introductory-overlay">
<div id="introductory-content">
<div id="introductory-container">
<h1 id="role-header">Junior Web Developer</h1>
<h3 id="role-support-text">...but that's not all I can do</h3>
<a id="read-more" class="no-select">Read More</a>
</div>
</div>
</div>
</div>
<div id="about-section">
<br />
<br />
<div id="photo-frame">
<div id="picture"></div>
</div>
<br />
<div id="about-text-container">
<p>Hi There! My name is Ed Garbutt, a Junior Web Developer based in South Buckinghamshire, with a huge passion for all things programming.</p>
<br />
<p id="about-left-side" class="side-by-side">Sadly, I'm not like most Developer out thers. I don't drink Red Bull or Monster Cans. I'm not a fan of Start Wars. I don't read Marvel Comic Books, but I am someone who likes going outside here and then.</p>
<p id="about-right-side" class="side-by-side">All jokes aside, what you <b>will</b> get is someone who prides himself on attention to details, who will always rise to a challenge ans is constantly looking to better himself, building upon his existing knowledge of programming languages and frameworks.</p>
</div>
</div>
</div>
<footer>
<p id="footer-text">
© 2016 Ed Garbutt. All rights reserved.
</p>
</footer>
</body>
CSS
body {
margin: 0;
}
nav {
width: 100%;
height: 50px;
position: fixed;
background-color: rgb(40, 40, 40);
border-bottom-style: solid;
border-bottom-color: rgb(238, 0, 0);
border-bottom-width: 7.5px;
padding-top: 14px;
z-index: 10;
}
#logo {
position: relative;
bottom: 5px;
font-size: 30px;
padding-left: 8px;
float: left;
font-family: bebas;
}
#word-1 {
color: rgb(0, 154, 205);
}
#word-2 {
color: rgb(255, 250, 250);
}
ul#main-links {
list-style: none;
margin: 0;
padding-right: 50px;
float: right;
height: 100%;
border-bottom: 7.5px solid transparent;
display: block;
font-size: 0;
}
ul#main-links li {
display: inline-block;
text-align: center;
border-bottom-style: solid;
border-bottom-width: 7.5px;
border-bottom-color: rgb(238, 0, 0);
color: white;
font-family: arcon;
font-size: 18px;
height: 100%;
width: 90px;
position: relative;
z-index: 2;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: white;
}
a:active {
text-decoration: none;
color: white;
}
a#logo-link {
text-decoration: none;
}
a#logo-link:visited {
text-decoration: none;
color: inherit;
}
a#logo-link:active {
text-decoration: none;
color: inherit;
}
ul#main-links > a > li > span.word-position {
position: relative;
top: 5px;
}
#menu-icon {
height: 48px;
width: 48px;
display: none;
cursor: pointer;
background-image: url("../images/hamburg-white-2.png");
}
#main-container {
padding-top: 71.4px;
}
#media screen and (min-width: 656px) {
ul#main-links {
display: block !important;
}
}
#media screen and (max-width: 656px) {
nav {
height: initial;
}
#logo {
width: 100%;
float: none;
padding-left: 0;
text-align: center;
bottom: 8px;
}
#menu-icon {
display: inline-block;
/* float: right;*/
position: absolute;
right: 10px;
top: -2px;
}
ul#main-links {
display: none;
float: none;
padding-right: 0;
padding-left: 0;
width: 100%;
}
ul#main-links li {
width: 100%;
display: block;
border: none;
padding: 10px 0;
}
ul#main-links li:not(.last-child) {
border-bottom-style: solid;
border-bottom-color: rgb(238, 0, 0);
border-bottom-width: 2.5px;
}
ul#main-links > a > li > span.word-position {
top: 0px;
}
#main-container {
padding-top: 62.4px;
}
}
#media screen and (max-width: 400px) {
#logo {
bottom: 7.5px;
font-size: 23px;
padding-left: 10px;
text-align: left;
}
#menu-icon {
height: 32px;
width: 32px;
background-image: url("../images/hamburg-white-1.png");
top: 0.4px;
right: 20px;
}
#main-container {
padding-top: 52.4px;
}
}
/* ----INTORDUCTION---- */
#introductory-background {
background-image: url('../images/eternity-1024x768.jpg');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
/* min-height: 527px;*/
height: 90vh;
background-size: 100% 100%;
overflow: auto;
}
#introductory-overlay {
display: table;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
#introductory-content {
margin-left: auto;
margin-right: auto;
display: table-cell;
vertical-align: middle;
text-align: center;
}
#introductory-container {
position: relative;
bottom: 60px;
}
h1#role-header {
display: block;
position: relative;
right: 5em;
opacity: 0;
font-size: 48px;
color: rgb(255, 250, 250);
}
h3#role-support-text {
display: block;
opacity: 0;
position: relative;
top: 20px;
font-size: 30px;
color: rgb(255, 250, 250);
}
#read-more {
border-radius: 38px;
background-color: rgb(255, 250, 250);
padding: 0.5em 1.5em;
font-size: 24px;
cursor: pointer;
}
#media screen and (max-width: 656px) {
#introductory-container {
bottom: 60px;
}
h1#role-header {
font-size: 37px;
}
h3#role-support-text {
top: 15px;
font-size: 24px;
}
#read-more {
font-size: 19px;
}
}
#media screen and (max-width: 400px) {
#introductory-container {
bottom: 72.5px;
}
h1#role-header {
font-size: 28px;
}
h3#role-support-text {
top: 11px;
font-size: 20px;
}
#read-more {
font-size: 16px;
}
}
/* -------------------- */
/* -------ABOUT-------- */
#about-section {
width: 100%;
height: 500px;
background-color: rgb(131, 111, 235);
}
#photo-frame {
margin: 0 auto;
background-color: royalblue;
width: 180px;
height: 180px;
border-radius: 100px;
border-style: solid;
border-color: beige;
border-width: 7.5px;
z-index: 2;
}
#photo-frame > #picture {
width: 100%;
height: 100%;
background-image: url('../images/Ed.png');
border-radius: 100px;
}
#about-section > #about-text-container {
margin: 0 auto;
width: 80%;
}
#about-section > #about-text-container > p {
margin: 0;
text-align: center;
/* padding: 0 3rem;*/
font-size: 22px;
}
#about-section > #about-text-container > p.side-by-side {
/* display: inline-block;*/
width: 45%;
text-align: justify;
}
#about-section > #about-text-container > p#about-left-side {
float: left;
}
#about-section > #about-text-container > p#about-right-side{
float: right;
}
#media screen and (max-width: 868px) {
#about-section > #about-text-container > p.side-by-side {
/* display: inline-block;*/
width: 100%;
}
#about-section > #about-text-container > p#about-left-side {
float: none;
padding-bottom: 1.5rem;
}
#about-section > #about-text-container > p#about-right-side{
float: none;
}
}
#media screen and (max-width: 656px) {
#photo-frame {
width: 150px;
height: 150px;
}
#about-section > #about-text-container {
width: 90%;
}
#about-section > #about-text-container > p {
text-align: justify;
padding: 0 1.5rem;
font-size: 20px;
}
}
#media screen and (max-width: 400px) {
#photo-frame {
width: 125px;
height: 125px;
}
#about-section > #about-text-container {
width: 100%;
}
#about-section > #about-text-container > p {
padding: 0 0.5rem;
font-size: 18px;
}
}
/* -------------------- */
/* -------FOOTER------- */
footer {
width: 100%;
background-color: black;
}
footer > p#footer-text {
margin: 0;
text-align: center;
font-family: arial;
color: rgb(169, 169, 169);
padding: 20px;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* -------------------- */
.no-select {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
Try this:
#about-section {
width: 100%;
background-color: rgb(131, 111, 235);
}
Description
You are using #about-section id remove the height property or use height:auto, you have given a fixed height. And use float:left as well in p tag ids.
here your update code
So this boils down to your p.side-by-side definition which is set at 45%.
If you want to not have columns on small screen sizes, then the approach would be to only set that 45% value with a break-point above mobile.
Your using a non-mobile first approach that makes this stuff harder (in my opinion). The easier way to go about it is to not add any width styles to those columns, and only add the 45% and the float, once the screen is above (say) 768px. In other words your media queries will generally have min values, not max.
I think a good way to start to think mobile-first is to realise that mobile layouts use kind of "less" CSS than desktops. So you keep it simple, just using semantic html, and then add in styles as the screen size increases to start making columns etc.
I am working on a mobile responsive website.
I have the navigation menu with the fixed position.
Right after I close the nav-menus div I have an image that has to be right under it. The thing is that the image goes under the fixed div of the menu.
What is the solution for this?
I want the yellow banner to be fully visible under the nav bar. now it's just under + behind it.
This is an example of what I have :
HTML code:
<!DOCTYPE html>
<html >
<body style="height:100%;">
<div data-role="panel" id="menu" class="" style="padding: 45px 0; margin: 0; " >
<div class="ui-panel-inner">
// the main menu in the background
</div>
</div>
<div id="superDiv" style="background-color: white; -webkit-transition: width 2s; transition: width 2s; height: 130%; ">
<div class="main" style="height: 100%;">
<div class="sidebar">
// menu items
</div>
<div class="header_space"></div> // I used this but it's now working good with precentages..
<img src="banner.png" id="mob-banner"/> // this is the banner
<div class="dynamicPage">
// content of the page..
</div>
</div>
</div>
</body>
</html>
The CSS code:
/******************/
/*** MOBILE ******/
/****************/
.header_space{
display: none;
height: 5.1%;
}
#mob-menu-btn{
display: none;
}
.sub-menu{
display: none;
}
#mob-home-btn{
display: none;
}
#mob-logo{
display: none;
}
#mob-banner{
display: none;
}
.makeFixed{
position: fixed;
}
/*****************************************************************/
#media (max-width: 604px) {
.main{
width: 100%;
/*overflow: hidden;*/
overflow-x: hidden;
}
.sidebar{
float: initial;
width: 100%;
padding: 0;
position: fixed;
z-index: 100;
background-image: url('top_background.png');
text-decoration: none;
}
.header_space{
display: inherit;
height: 4.7%;
}
.sports{
/*display: none;*/
padding: 0 ;
background-color: #fff;
margin: 0;
width:100%;
}
.list{
width: 100%;
overflow: hidden;
overflow-y: auto;
top: -10%;
overflow: hidden;
overflow-y: auto;
height: 880%;
display: none;
}
.sports li{
list-style-image:none;
list-style-type: none;
border-bottom: 2px solid #eeeeee;
margin-bottom: 0px;
margin-left: 0px;
/*padding-top: 15px;
padding-bottom: 15px;*/
padding-left: 10px;
width:100%;
font-family: arial;
text-decoration: none;
overflow: hidden;
/*height: 27px;*/
z-index: 100;
}
.sports a li {
text-decoration: none;
}
.sports2{
display: none;
margin-bottom: 0;
overflow: hidden;
}
.sub-menu{
display: inherit;
float: left;
cursor: pointer;
width: 30px;
/*margin-right: 20px;*/
position: relative;
bottom: 7px;
z-index: 900;
position: relative;
top: 7px;
padding-right: 17px;
}
.sports2 li{
list-style-image:none;
list-style-type: none;
border-bottom: 0px solid #eeeeee;
margin-bottom: 0px;
margin-left: 0px;
/*padding-top: 15px;
padding-bottom: 15px;*/
padding-left: 0px;
width:100%;
font-family: "arial";
text-decoration: none;
overflow: hidden;
}
.sports2 div{
padding: 15px 0;
}
#mob-menu-btn{
float: right;
width: 10%;
display: inherit;
cursor: pointer;
margin-top: 0.8%;
}
#mob-home-btn{
display: inherit;
cursor: pointer;
margin-top: 0.8%;
width: 10%;
float: left;
}
#mob-logo{
display: inherit;
text-align: center;
margin: 0.2% auto;
width: 30%;
}
#mob-banner{
display: inherit;
}
.banner{
display: none;
}
.content{
width:100%;
background-color: white;
}
.logo{
padding-top: 1px;
}
#cat-header{
display: none;
}
.line{
display: none;
}
.table {
width: 100%;
}
#top-pages{
display: none;
}
.top-pages{
display: none;
}
.category-link{
float:left;
padding-top: 25px;
width: 510px;
padding: 15px 0;
}
.content h1 {
color:#031c3f;
font-size:24px;
text-align: left;
font-family: "UScoreRGK";
margin-left: 7px;
}
.content p {
margin-left: 10px;
margin-right: 10px;
}
#active_line{
margin-left: 10px;
margin-right: 10px;
}
#menu {
z-index: 0;
top: 0px;
position: absolute;
/*right: 0px!important;
left: auto!important;*/
}
#menu li {
list-style: none!important;
}
}
#media (min-width : 414px) and (max-width : 533px) {
.category-link{
width: 460px;
}
}
#media (min-width : 375px) and (max-width : 414px) {
.category-link {
width: 340px;
}
.wcmText ul, ol{
margin: 0 0 1em -2.5em;
}
.wcmText p{
margin-top: 0;
}
.wcmText h1, h2{
margin-top: 0;
margin-bottom: 0;
font-size: 110%;
}
}
#media (min-width : 360px) and (max-width : 375px) {
.category-link {
width: 282px;
}
.sidebar{
height: 38px;
}
}
#media (min-width : 320px) and (max-width : 360px) {
.wcmText ul, ol{
margin: 0 0 1em -2.5em;
}
.wcmText p{
margin-top: 0;
}
.wcmText h1, h2{
margin-top: 0;
margin-bottom: 0;
font-size: 110%;
}
}
#media (min-width : 240px) and (max-width : 320px) {
.sidebar{
background-image: url('top_background-320-2.png');
height: 52px;
}
#mob-menu-btn {
width: 7%;
margin-top: 4.8%;
margin-right: 4%;
}
#mob-home-btn {
width: 7%;
margin-top: 4.8%;
margin-left: 4%;
}
#mob-logo {
margin: 2% auto;
width: 45%;
}
.header_space {
height: 52px;
}
.list {
width: 99.5%;
overflow: hidden;
overflow-y: auto;
top: -9%;
overflow: hidden;
overflow-y: auto;
height: 803%;
}
.sports li {
width: 96%;
}
.content h1 {
color:#031c3f;
font-size:24px;
text-align: left;
font-family: "UScoreRGK";
margin-left: 7px;
}
.content p {
margin-left: 10px;
margin-right: 10px;
}
.category-link{
float:left;
padding-top: 25px;
width: 230px;
padding: 15px 0;
}
}
It looks like the only thing you are missing to make the ".header_space" work is to add
style="height: 100%;" to your HTML tag
<html style="height: 100%;">
or in your CSS
html { height:100% }
all your height properties, for example "height:100%" on the BODY tag, are not working.
although, i don't think your solution is an elegant one.
I would prefer to add
#media (max-width: 604px) {
/* lets say 50px is the height of your mobile menu */
#mob-banner { margin-top: 50px; }
}
to the the media query that handles your mobile views, instead of
<div class="header_space"></div>