header overlapping content when page size changes HTML - html

Im having an issue where I want my header to be fixed to the top of the web browser, same with the nav bar i made. Problem is, when I change the size of the web browser, the header covers the content and moves the nav bar. How can I solve this?
<body>
<h1>Knox Enterprises Inc.</h1>
<div class="nav">
Home
About
Contact
</div>
<div class="adjust">
<div class="home">
<div class="home-pictures">
<img src="http://i64.tinypic.com/14o91c1.jpg" width="300px" height="225px">
<img src="http://i63.tinypic.com/2rpzh3p.jpg" width="300px" height="225px">
</div>
<div class="home-pictures2">
<img src="http://i68.tinypic.com/rswqoy.jpg" width="300px" height="225px">
<img src="http://i66.tinypic.com/2lm8bdg.jpg" width="300px" height="225px">
</div>
<div class="home-description">
<ul>
<h5>Riveredge, NJ</h5>
<h5>Date Completed: June 2014</h5>
</ul>
</div>
<div class="home">
<div class="home-pictures">
<img src="home_5.jpg" width="300px" height="225px">
<img src="home_6.jpg" width="300px" height="225px">
</div>
<div class="home-pictures2">
<img src="home_7.jpg" width="300px" height="225px">
<img src="home_8.jpg" width="300px" height="225px">
</div>
<div class="home-description">
<ul>
<h5>Teaneck, NJ</h5>
<h5>Date Completed: March 2015</h5>
</ul>
</div>
<div class="home">
<div class="home-pictures">
<img src="home_9.jpg" width="300px" height="225px">
<img src="home_10.jpg" width="300px" height="225px">
</div>
<div class="home-pictures2">
<img src="home_11.jpg" width="300px" height="225px">
<img src="home_12.jpg" width="300px" height="225px">
</div>
<div class="home-description">
<ul>
<h5>Tenafly, NJ</h5>
<h5>Date Completed: August 2016</h5>
</ul>
</div>
</div>
</body>
and my .css code is
html, body {
margin: 0;
padding: 0;
background-image:url("backround.jpg");
background-repeat: repeat-y;
}
/*Knox Header*/
h1 {
position: fixed;
top: -40px;
width: 100%;
font-family: Georgia;
color: white;
text-shadow: 4px 4px black;
background-image: url("header.jpg");
font-size: 60px;
text-align: center;
text-transform: uppercase;
border-bottom: 5px solid orange;
border-top: 5px solid orange;
}
/*Nav Menu/Home Page*/
.nav {
position:fixed;
padding-top:78px;
background-image:#606060;
overflow: hidden;
}
.nav a {
font-family: Helvetica;
background-color:black;
float: left;
color: #f2f2f2;
text-align: center;
padding: 10px 12px;
text-decoration: none;
font-size: 12px;
border-right: 2px solid orange;
border-bottom: 2px solid orange;
border-top: 2px solid orange;
letter-spacing: 2px;
}
.nav a:hover {
background-color: #ddd;
color: black;
}
.home {
text-align:center;
padding-top: 10px;
padding-bottom: 10px;
}
.home-pictures, .home-pictures2{
height:auto;
width:auto;
display: inline-block;
margin-left: auto;
margin-right: auto;
}
.home img {
border: 1px solid white;
}
.home-description {
line-height: 0px;
color: white;
letter-spacing: 2px;
font-family: Helvetica;
font-size: 18px;
}

Put both elements inside a container and make this container fixed instead of using two elements with position: fixed.
They are both put out of flow and thus they will not be affected by each other (thus the navigation bar will be overlapped by the h1 when there is not enough width for the content so that it has to break the line)
https://jsfiddle.net/7ntdes6t/

I'd start by wrapping your header and nav bar in it's own tag, like:
<header class='header-fixed'>
<h1>Knox Enterprises Inc.</h1>
<div class="nav">
Home
About
Contact
</div>
</header>
Then, you only have to worry about one fixed-position element.
From there, you have some options.
You could use javascript to watch for window resizes and adjust the margin-top on your accordingly.
You could figure up exactly how tall your header is at common browser sizes, and use media queries to adjust the rest.
Edit:
Actually, you know what would be easier?
<header>
...
</header>
<div id="Content">
...
</div>
header {
height: 120px;
}
#content {
height: calc(100% - 120px);
overflow-y: scroll;
}
If you can figure out exactly how tall your header is, then you could use calc() to set the height of the rest of your content, and actually make that div the part that scrolls. At that point, you don't need fixed positioning.

Related

I cannot align the footer to the right

I would like to know if someone could help me with a CSS topic.
I am creating a page model through CSS, but it turns out that there is a part that does not stay the same as the rest.
It appears as follows:
enter image description here
And it should look like this, like the footer in the following image.
Do you suggest any ideas? I leave here the code that I have used for CSS.
enter image description here
I attach the HTML and CSS code used.
I tried to move the height and width but can't find the solution.
<!--Inicio de pie de página-->
<div class="clearfix"></div>
<footer id="footer">
<div class="wrap">
<div id="menu_footer">
<h5>Menú</h5>
<ul>
<li>Inicio</li>
<li>Blog Personal</li>
<li>Currículum</li>
<li>Contacto</li>
</ul>
</div>
<div id="location">
<h5>¿Dónde estamos?</h5>
<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3037.4968410733713!2d-3.690925684351!3d40.41999606336424!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd42289a4a865227%3A0x98278b3a144a86f1!2sPuerta%20de%20Alcal%C3%A1!5e0!3m2!1ses!2ses!4v1599489227264!5m2!1ses!2ses"
width="600" height="450" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false"
tabindex="0">
</iframe>
<div id="info">
<h5> Desarrollado con</h5>
<p>
<img src="img/html5-badge-h-css3-graphics-multimedia-performance-semantics.png"
alt="Creado con HTML y CSS">
</p>
<h5>Optimizado para</h5>
<p id="browsers">
<a href="#">
<img src="img/firefox-icon.png" alt="Firefox" title="Firefox">
</a>
<a href="#">
<img src="img/chrome.png" alt="chrome" title="Chrome">
</a>
<a href="#">
<img src="img/Opera_256x256.png" alt="Opera" title="Opera">
</a>
<a href="#">
<img src="img/safari.png" alt="Safari" title="Safari">
</a>
<a href="#">
<img src="img/android.png" alt="Android" title="Android">
</a>
<a href="#">
<img src="img/ios.png" alt="Apple" title="Apple">
</a>
</p>
<h5>Autor</h5>
<p>&COPY;Cristina Martínez - acmartinez96.blogspot.com</p>
</div>
</div>
</div>
</footer>
<!--Fin de pie de página-->
</body>
</html>
/FOOTER/
#footer h5
display: block;
background: url(../img/pxgray.png), white;
height: 55px;
letter-spacing: 2px;
text-align: center;
font-family: "BebasNeue";
font-size: 40px;
line-height: 55px;
color: black;
border-radius: 5px;
margin-bottom: 15px;
#footer ul
text-align: left;
margin: 20px;
font-size: 25px;
#footer ul li
margin-top: 10px;
padding: 5px;
border-bottom: 1px solid #cccccc;
#footer ul li a
display: block;
height: 40px;
#footer iframe
width: 100%;
height: 300px;
margin-top: 10px;
border-radius: 5px;
box-shadow: 0x 0px 5px grey;
border: 5px solid white;
}
#footer img
margin-bottom: 15px;
#footer #browsers img{
width: 45px;
Thanks!
Try to use flexbox it's very helpful.
the rendering you request can be done simply this way
<div class="flex">
<div class="ll">Menu</div>
<div class="ll">Map</div>
<div class="ll">Footer</div>
</div>
div.ll {
background: #fff;
margin: 20 auto;
width: 200px;
padding: 50px;
text-align: center;
}
div.flex {
display: flex;
}
You can test it by using sandbox
Instead of a footer, try creating a <div> or <section> and align that to the right.

How do I get rid of whitespace below a div when translating that div up?

I have translated an image up to go behind a div to make it fit the design, however it leaves a white space below it, where the original image would be. How would I go about fixing this?
This is for a website, I've tried translating the sitemap up however then there is even more white space below the sitemap.
HTML:
<div class="portfolioImage" id="images">
<div class="portLogoImages" id="myDIV5">
<img src="./resources/portfolio/logoportfolio/logoPortfolio1.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio2.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio3.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio4.png" alt="" class="portfolioImages">
<img src="./resources/portfolio/logoportfolio/logoPortfolio5.png" alt="" class="portfolioImages">
</div>
</div>
<div class="sitemap portAdjustment"> <!-- SITEMAP -->
<div class="sitemapItems">
<img src="./resources/sitemapLogo.png" alt="" class="sitemapLogo" width="166.3px" height="22px">
<div class="links">
<p >Home</p>
<p>Products</p>
<p>Portfolio</p>
<p>About Us</p>
<p>Contact Us</p>
</div>
<div class="finePrint">
<p>X is a part of the family company X that specialises in custom made design ranging from logo design to apparel design.</p>
<p>X</p>
</div>
</div>
</div>
CSS:
.portfolioImages {
border: none;
font-size: 0px;
transform: translateY(-25px);
max-width: 100%;
}
.portLogoImages {
border: none;
font-size: 0px;
transform: translateY(-25px);
max-width: 100%;
height: auto;
width: 100%;
margin-left: auto;
margin-right: auto;
}
.sitemap {
width: 100%;
height: 215px;
background-color: #f4f4f4;
padding: 30px 0px 30px 0px;
display: block;
text-align: center;
}
.finePrint {
padding-top: 70px;
color: #c8c8c8;
}
.sitemapItems {
padding: 0px 30px 0 30px;
display: block;
}
.sitemap a {
text-decoration: none;
color: #c8c8c8;
transition-duration: .2s;
display: inline-block;
padding-right: 4px;
}
.sitemap a:hover {
text-decoration: underline;
color: #434343;
}
I expect there to be no white space however there is still white space below it.
Just use margin-top instead transform

need logo in center of page section excluding left sidebar in squarespace

website :https://wells-demo.squarespace.com/
Need logo in center of page section excluding left sidebar(header) in squarespace WELLS template on all format mobile,desktop etc.I am trying to figure out but no result.following is my code
$(document).ready(function(){
$('#headerWrapper #header ').after('<div id="logo1" data-content-field="site-title"><h1 class="logo image" data-shrink-original-size="23" style="letter-spacing: 0.0869565em;"><img src="//static1.squarespace.com/static/5adfd10929711421a9b29d21/t/5adfdbac562fa79909bad158/1524908392416/?format=750w" alt="L ETO BRIDAL" width="130" height=50"></h1></div>');
});
#logo{display:none;}
#headerWrapper{top:4px!important}
#logo1 h1 a img {
height:70px!important;
}
#logo1 {
left: 300%;
position: absolute;
text-align: center !important;
top: 10px !important;
transform: translateX(-50%);
Based on your current CSS, this should do it:
#logo {
width: 100%;
text-align: center;
}
#media (min-width: 801px) {
#logo {
position: fixed;
width: calc(100% - 340px);
top: 0;
margin-left: 240px;
box-sizing: border-box;
background-color: #ffffff85;
padding: .5rem 0;
border-bottom: 1px solid #fff;
}
}
Note: in current form, your question is not really useful to future visitors.
You can read the structure i made below using w3.css from w3schools. I have given a border colour to every div so you can see the boundary of that div and it will make it easy to learn for you.
.outer
{
border:1px solid red;
min-height:100px;
width:100%;
}
.inner-left
{
border:1px solid green;
}
.inner-right
{
border:1px solid blue;
}
.centetr
{
text-align:center;
}
.photo
{
width:95%;
margin:0px auto;
height:40px;
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div class="w3-container outer">
<!--left side-->
<div class="w3-quarter inner-left">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
</ul>
</div>
<div class="w3-rest inner-right">
<div class="w3-container w3-margin-bottom centetr">
NAME
</div>
<div class="w3-container">
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
<div class="w3-half">
<img src="" class="photo">
</div>
</div>
</div>
</div>

Horizontal alignment of 3 boxes of div

I'm create html page called AboutUs.html. I was tasked to complete the page but there is a problem. I want to align the three box in horizontally something like this:
but I try using some CSS code but still could not align in horizontal.
Wrong Output:
I want the first box to be left, for second box to be center and the third box to be right. Can anyone please help me fix this problem.
This is About.html code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Two Trees Creative - About Us </title>
<link rel="stylesheet" href="_stylesheets/Css_Reset.css"/>
<link rel="stylesheet" href="_stylesheets/mystyle.css"/>
</head>
<body>
<div id="wrapper">
<header>
<a id="logo" href="#">Two Tree Creative</a>
<nav id="mainNav">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</nav>
</header>
<section id="welcome">
<h1>Designing your world</h1>
<p>One pixel at a time</p>
</section>
<section id="about">
<h2>About us</h2>
<article id="about_info">
<p>Two Trees Creative is a full-service graphic design agency based in Ventura, CA. Our goal is to provide elegant work and unsurpassed customer service to our clients in every way.</p>
<h3>Meet Our Team of Creatives</h3>
<p>Collectively we have over 15 years experience in the graphic design industry, and our services include brand identity development, business cards, brochures, flyers, catalogs, and more. Thank you for considering us for your next project, and we hope to hear from you soon.</p>
</article>
<aside id="about_team">
<div class="row">
<div class="image">
<img src="_images/team/alex_morrales.jpg" alt="Alex Morrales" width="150" height="150">
<p>Alex Morrales</p>
</div>
<div class="image">
<img src="_images/team/david_kim.jpg" alt="David Kim" width="150" height="150">
<p>David Kim</p>
</div>
<div class="image">
<img src="_images/team/jenny_tabers.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
</div>
<div class="row"></div>
</aside>
</section>
<footer>
<p>Photoshop adapted from www.lynda.com - Photoshop CC for Web Designed by Justin Seeley</p>
</footer>
</div>
</body>
</html>
For mystyle.css code, under about_team id element i need to code something in order for the 3 box to be align in horizontally.
#wrapper {
max-width: 1280px;
margin: auto;
}
/*header*/
header {
background-color: white;
width:100%;
height: 165px;
text-align: center;
margin-top: 60px;
}
#logo {
background: url(../_images/ttc_logo.png) no-repeat;
width: 85px;
height: 85px;
margin: auto;
margin-bottom: 0px;
display: block;
text-indent: -9999px;
}
#welcome
{
background: url(../_images/banner.jpg);
width:100%;
height:650px;
overflow:hidden;
text-align:center;
color:white;
vertical-align:middle;
}
#welcome h1
{
font-size:4em;
font-family:'Adobe Garamond , serif';
padding-top:200px;
text-transform:uppercase;
}
#welcome p
{
font-size:3em;
font-family:'Adobe Garamond , serif';
font-style:italic;
font-weight:bold;
}
#about
{
margin:auto;
height:550px;
background-image:url(../_images/tree1.gif), url(../_images/tree1.gif);
background-position:-150px, 115%;
background-repeat:no-repeat, no-repeat;
}
#about h2
{
text-align:center;
text-transform: uppercase;
font: 3em 'Adobe Garamond, serif';
font-weight:bold;
padding-top:50px;
margin-bottom:25px;
color:rgb(82, 71,65);
}
#about h3
{
font:36px Arial, sans-serif;
margin-top:60px;
margin-bottom:10px;
color:rgb(134,118,92);
}
#about_info{
float:left;
margin: 0 auto;
padding-top:37px;
width:40%;
height:400px;
padding-left:125px;
}
#about_team
{
float:left;
margin: auto;
height:400px;
padding-top:37px;
padding-left:20px;
}
#mainNav{
width: 680px;
margin: auto;
}
#mainNav ul li {
margin: 0;
padding: 0;
list-style-type: none;
display: inline;
}
#mainNav li a:link{
text-align: center;
display: block;
float: left;
width: 110px;
text-decoration: none;
text-transform: uppercase;
color: #5b866b;
margin: 20px 20px;
height: 20px;
padding: 5px;
border-radius: 5px;
}
#mainNav ul li a:hover,
#mainNav ul li a:focus
{
background: rgb(185,140,72);
color: white;
box-shadow: 2px 3px 4px 0px #CC9933;
}
footer{
background-color: #dee7e1;
text-align:center;
height:20px
padding:20px;
clear:both;
}
https://jsfiddle.net/ow6hc90f/1/
Just add
.image {
float: left;
}
and remove the float from this
#about_team {
/* float:left; */
margin: auto;
height:400px;
padding-top:37px;
padding-left:20px;
}
You can use CSS Flexbox. Make your three .image divs wrap under a parent div (.image-block - in my case).
Look at this Codepen
Something like this:
.image-block {
display: flex;
justify-content: center;
}
.image {
margin-right: 10px;
text-align: center;
}
<div class="image-block">
<div class="image">
<img src="http://placehold.it/200x200" alt="Alex Morrales" width="150" height="150">
<p>Alex Morrales</p>
</div>
<div class="image">
<img src="http://placehold.it/200x200" alt="David Kim" width="150" height="150">
<p>David Kim</p>
</div>
<div class="image">
<img src="http://placehold.it/200x200" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
</div>
Hope this helps!
Add width: 3 times (imageWidth+margin) into #about_team and add width: 150px and display: inline-block into .image. font-size: 0 in #about_team is to remove space between inline-block element, and you need to restore the size in the .image.
#about_team {
width: 480px;
float: right;
font-size: 0;
}
#about_team .image{
display: inline-block;
width: 150px;
margin-right: 10px;
font-size: 14px;
}
<aside id="about_team">
<div class="row">
<div class="image">
<img src="https://avatars3.githubusercontent.com/u/1024025?v=3&s=400" alt="Alex Morrales" width="150" height="150">
<p>Alex Morrales</p>
</div>
<div class="image">
<img src="https://pbs.twimg.com/profile_images/558109954561679360/j1f9DiJi.jpeg" alt="David Kim" width="150" height="150">
<p>David Kim</p>
</div>
<div class="image">
<img src="http://a5.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE5NDg0MDU0NTIzODQwMDE1.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
<div class="image">
<img src="http://a4.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE1ODA0OTcxNjk3OTMxNzg5.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
<div class="image">
<img src="http://i142.photobucket.com/albums/r96/thisdayinmusic/PaulMcCartneyHandsomePaul.png" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
<div class="image">
<img src="http://static.giantbomb.com/uploads/original/8/84561/1465721-georgeharrison.jpg" alt="Jenny Tabers" width="150" height="150">
<p>Jenny</p>
</div>
</div>
</aside>

Anchor tags not working

I have a few anchor tags in my html that for some reason aren't working. As far as I can tell there is nothing wrong with the code so I am completely at a loss. Maybe I need a fresh pair of eyes to look it over to see if there is something obvious that I am missing? This website is not loaded onto a server yet but here is the code I am having issues with.
<div id="navigation">
<div class="wrapper">
<div class="right">
<div class="phone-number">
<p>24hr Turn Around Time 1-877-229-9665</p>
</div>
<div class="social-media">
<img src="images/facebook.png">
<img src="images/twitter.png">
<img src="images/yelp.png">
</div>
</div>
<div class="left">
<div class="logo">
<img src="images/logo.png">
</div>
<div class="text">
<p>Custom Made Orthotics</p>
</div>
</div>
<div class="navbar">
<nav>
HOME
SERVICES
COMPANY
CONTACT US
NEWS
</nav>
</div>
<div class="clear"></div>
</div>
</div>
#header {
font-family: calibri;
}
.text {
text-align:left;
font-size: 20px;
}
.navbar {
text-align: center;
font-color: #000000;
padding: 30px 20px 4px;
}
.phone-number {
text-align: right;
}
#navigation {
position: fixed;
top: 0;
width: 100%;
color: #000000;
height: 80px;
padding-top: 5px;
background-color: #ffffff;
z-index: 1;
}
#navigation a {
font-size: 20px;
padding-left: 5px;
padding-right: 15px;
color: #000000;
text-decoration: none;
}
#navigation a:hover {
color: grey;
}
.social-media {
text-align: right;
margin-top: 40px;
}
Fiddle, they seem to actually be working, as in they are all working links.
<div class="social-media">
<img src="images/facebook.png">
<img src="images/twitter.png">
<img src="images/yelp.png">
</div>
</div>
Ok so I had a co-worker fix this issue. changed the position to relative and added a z-index of 20. Now they are working!