Push down div when above div expands? - html

Making a single page website. The HTML is as follows
<!-- Landing Page-->
<div id="landing">
<img src="front.png" alt="Cover Page">
</div>
<!-- About -->
<div id="page1">
<a id="about"></a>
<img src="Who.png" alt="About Me">
<p>
xxx
</p>
</div>
<!-- Work -->
<div id="page2">
<a id="portfolio"></a>
<div id="container">
<a class="fancybox" href="portfolio1.jpg" title="'Consumed' </br>Digital/Print Work"><img src="portfolio1s.png"/></a>
</div>
</div>
<!-- Contact -->
<div id="page3">
<a id="contact"></a>
<img src="Contact.png" alt="Contact Information">
<p>
xxx
</p>
</div>
</body>
I removed the image links from the div #container, but altogether there are more than 10. My issue is when I make the window narrow (to see how it will be viewed on a mobile device), the images in div #container overlap with my image on my contact page. I would like it such that when it expands, it pushes the contact page down. I've tried doing this with position:relative, but doesn't seem to work.
Relevant CSS:
#container
{
padding:50px;
display:table-cell;
vertical-align:center;
width:auto;
}
#container a img
{
padding:10px;
opacity:1.0;
filter:alpha (opacity=100); /*for >IE8 */
}
#page1 img
{
display:block;
margin-left:auto;
margin-right:auto;
width:400px;
position:relative;
top:15px;
}
#page2 {
height:1200px;
font-family: Arial, sans-serif;
font-weight: bold;
color:purple;
}
#page3 {
height:1200px;
font-family: Arial, sans-serif;
font-weight: bold;
color:red;
}
#page3 img
{
display:block;
margin-left:auto;
margin-right:auto;
margin-bottom:-20px;
width:400px;
position:relative;
top:15px;
}

Related

Min-height on class doesn't work

I'm creating a website, but have a little problem, that I don't know how to solve.
<div id="middle">
<div id="clock">Here shows JS clock</div><br>
<div class="element">
<img height="80px" src="SOURCE"/><h1 style="float:left" >TITLE TEXT</h1><div class="clearboth"></div>
TITLE TEXT
</div>
<div class="clearboth"></div>
<div class="element">
<img height="80px" src="SOURCE"/><h1 style="float:left">TITLE TEXT</h1><div class="clearboth"></div>
<p>SOME TEXT</p>
</div>
And CSS
.element{
background-color:#fff;
min-heigth:100px;
}
#middle{
font-family:'Roboto', monospace;
padding-left:5px;
padding-right:5px;
min-height:1000px;
width:1000px;
background-color:#ffffff;
margin:auto;
}
#middle > h1,h2,h3{
font-family: 'VT323', monospace;
font-size:34px;
margin-left:20px;
}
.clearboth{
clear:both;
}
#middle p{
text-indent: 40px;
font-size:18px;
}
But it min-height doesn't work - next element starts right after previous one.
From what I can tell, it doesn't seem like the height of the items is changing (i.e. with percentages, etc). This means that the height remains static, so there is no reason for the min-height to activate, in a sense. Try doing that and fixing the other errors that the others have pointed out. Hope this helps.
It seems to me that what you want is to have space between your elements, assuming that the code you write is corrected ("height" instead of "heigth" and the div#middle is closed), try adding to your element some margin at bottom.
.element {
background-color: #fff;
min-height: 100px;
margin-bottom: 30px; /* Add this line to separate each element for 30px */
}
If you don't need the margin on the last element just add a new selector to target the last .element in your code.
.element:last-of-type {
margin-botton: 0;
}
Try this, min-height spelled wrong and your #middle div isn't closed.
.element{
background-color:#fff;
min-height:100px;
}
#middle{
font-family:'Roboto', monospace;
padding-left:5px;
padding-right:5px;
min-height:1000px;
width:1000px;
background-color:#ffffff;
margin:auto;
}
#middle > h1,h2,h3{
font-family: 'VT323', monospace;
font-size:34px;
margin-left:20px;
}
.clearboth{
clear:both;
}
#middle p{
text-indent: 40px;
font-size:18px;
}
<div id="middle">
<div id="clock">Here shows JS clock</div><br>
<div class="element">
<img height="80px" src="SOURCE"/><h1 style="float:left" >TITLE TEXT</h1><div class="clearboth"></div>
TITLE TEXT
</div>
<div class="clearboth"></div>
<div class="element">
<img height="80px" src="SOURCE"/><h1 style="float:left">TITLE TEXT</h1><div class="clearboth"></div>
<p>SOME TEXT</p>
</div>
</div>

div not positioned correctly

I want the navigation bar to be at the bottom of the window when the page loads (but it will stick to the top while scrolling so I can't make its position fixed). The only thing I figured out is making the background div height 100vh minus navigation bar height but it creates that weird white padding instead of bringing the navigation up.
Also, how can I center vertically elements in my .navigation (and in the .tester too)? The logo has to be on the left side while navigation must be on the right.
Here's the code:
html,body {
min-width:320px;
min-height:320px;
margin:0;
font-family: 'Lato', sans-serif;
text-align:center;
}
h1 {
margin-top:0;
font-size:68px;
font-weight:bold;
}
.header-wrapper {
background-image: url("images/backgrounds/typography.jpg");
background-size:cover;
background-position:center;
min-height:calc(100vh - 6em - 100px);
text-align:center;
padding-top:6em;
margin:0 auto;
position:relative;
}
.tester{
position:absolute;
width:100%;
display:flex;
bottom:50px;
margin: auto;
align-items: center;
justify-content: center;
}
.tester a{
margin-left:1em;
margin-right:1em;
opacity: 0.75;
}
.tester a:hover{
opacity:1;
}
.slider-buttons {
position:absolute;
max-width:1170px;
}
.typography {
bottom: 100px;
left:auto;
}
.navigation {
max-width:1170px;
margin:0 auto;
height:94px;
background-color:white;
bottom:0;
}
nav {
float:right;
text-transform:uppercase;
}
nav a {
text-decoration:none;
color:#626262;
padding:40px 20px 40px 20px;
margin:0;
}
nav #home:hover, #menu2:hover, #menu3:hover, #menu4:hover, #menu5:hover {
color:white;
}
nav #home:hover {
background-color:#dfbb42;
}
nav #menu2:hover {
background-color:#c43434;
}
nav #menu3:hover {
background-color:#508b61;
}
nav #menu4:hover {
background-color:#428d9e;
}
nav #menu5:hover {
background-color:#575fbd;
}
#logo {
float:left;
margin-left:30px;
}
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>random title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
</head>
<body>
<section>
<div class="header-wrapper">
<h1>Lorem ipsum sit dolor amet</h1>
<div class="tester">
<a href="">
<div class="typography">
<img src="images/slider-buttons/typography/typography-icon.jpg">
<img src="images/slider-buttons/typography/typography-text.jpg">
</div>
</a>
<a href="">
<div class="typography">
<img src="images/slider-buttons/typography/typography-icon.jpg">
<img src="images/slider-buttons/typography/typography-text.jpg">
</div>
</a>
</a>
<a href="">
<div class="typography">
<img src="images/slider-buttons/typography/typography-icon.jpg">
<img src="images/slider-buttons/typography/typography-text.jpg">
</div>
</a>
</a>
</div>
</div>
</section>
<section id="menu2">
<div class="navigation">
<nav>
Home
Menu 2
Menu 3
Menu 4
Menu 5
</nav>
<img src="css/images/logo.png" alt="Logo" id="logo">
</div>
</section>
I guess that can only be done with JS, so you can change the nav position based on the window offset.
you can better use jquery to initially hide the nav-bar when the page loads using Jquery and show it as the user scrolls down the page.
here is the example:
$(document).ready(function(){
$(window).scroll(function(){
$('#navbar').fadeIn("slow");
setTimeout(function(){
if($(window).scrollTop()<10){
$('#navbar').fadeOut("slow");
}
},100)
})
})
#navbar{
position:fixed;
top:0px;
width:100%;
height:100px;
background:#eeeeee;
color:white;
text-align:center;
display:none;
}
#content{
height:1000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="navbar"><h1>lorem ipsum</h1></div>
<div id="content"></div>

I have an img that refuses to center and I can't figure out why?

I can't seem to center an image I have. The image is in a div surrounded by 2 other images. I have tried text-align and setting margin to auto but that doesn't seem to be working. The slider div below holding the slides should be centered but it's not.
Here's the html:
<body>
<div id = "container">
<h1>
Meet some of of our Members
</h1>
<img id="prev" src="images/rsz_back-button.png" alt="prev">
<div id="Slider">
<div class = "slide active">
<div id ="slide-copy">
<h2>
Echo
</h2>
</div>
<img src="images/rsz_a0615655ad9ed49f75bf617e2df6a47c.jpg"> </div>
<div class = "slide">
<div id ="slide-copy">
<h2>
Victor
</h2>
</div>
<img src="images/rsz_dollhouse-tv-show-2.jpg"> </div>
<div class = "slide">
<div id ="slide-copy">
<h2>
Sierra
</h2>
</div>
<img src="images/rsz_0000053222_20081110111439.jpg"> </div>
<div class = "slide">
<div id ="slide-copy">
<h2>
Alpha
</h2>
</div>
<img src="images/rsz_1alan-tudyk-transformers.jpg"> </div>
</div>
<img id="next" src="images/rsz_forward-button.png" alt="next"> </div>
</body>
and here is the css:
*{
margin:0;
padding:0;
}
body{
font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:14px;
color:#fff;
background:#333;
line-height:1.6em;
}
a{
color:#fff;
text-decoration:none;
}
h1{
text-align:center;
margin-bottom:20px;
}
#container{
text-align:center;
width: 980px;
margin:40px auto;
overflow:hidden;
}
#slider{
margin:40px auto;
position:relative;
width:512px;
height:385px;
overflow: hidden;
float: left;
padding:3px;
border: #666 solid 2px;
border-radius:2px;
z-index:0;
}
slider img{
width:512px;
height:385;
}
#prev, #next{
float:left;
padding-top:50px;
z-index:1;
}
The #Slider div comes right after the floating #prev div, which pushes the #Slider to the right.
Solution: don't float the #prev. Or clear the float in the #Slider, whatever you want. (If your intention is to show the #prev to the left of the screen, give it position:absolute or something.)
By the way, there are errors in your HTML. The ID slide-copy appears twice.
And errors in your css. 385 should be 385px, and slider and #slider should both be #Slider.

My DIV sits on top of the previous DIV

I have just started putting my site together. I have a scrolling banner DIV and now i want to add a an image underneath 'largemenubutton' DIV but when I place it just sits on top of my banner? I have put in the CSS to clear:left however this does not work.
html
<body>
<div class="mainhome">
<div class="header">
<div class="menubutton-leftside" style="margin-right:23px"><h2>home</h2></div>
<div class="menubutton-leftside" style="margin-right:20px"><h2>about</h2></div>
<div class="menubutton-leftside" style="margin-right:30px"><h2>portfolio</h2></div>
<div class="menubutton-leftside" style="margin-right:27px"><h2>contact</h2></div>
<div class="logo"><img src="images/es-logo.png" width="170" height="170" /></div>
<div class="menubutton-rightside" style="margin-left:17px"><h2>print</h2></div>
<div class="menubutton-rightside" style="margin-left:25px"><h2>digital</h2></div>
<div class="menubutton-rightside" style="margin-left:38px"><h2>illustration</h2></div>
<div class="menubutton-rightside" style="margin-left:20px"><h2>brand</h2></div>
</div>
<div class="mainimage">
<div id="slider_container">
<div id="slides">
<img src="images/slider/emmasteed.png" alt="Emma Steed Graphic Art and Web Design" />
<img src="images/slider/graphicdesign-desk.png" alt="Emma Steed Graphic Art and Web Design" />
</div>
</div>
<div class="bluebar"></div></div>
<div class="largemenubutton"><img src="images/portfolio.png" /></div>
</div>
css
#charset "UTF-8";
/* CSS Document */
body {
background-image:url(images/header-background.png);
background-repeat:repeat-x;
margin:0;
}
.mainhome {
width: 855px;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
}
.header {
height: 236px;
background-image:url(images/header-background.png);
background-repeat:repeat-x;
clear:left;
}
.mainimage {
width: 855px;
height: 423px;
background-color:#0C9;
position:absolute;
top:220px;
clear:left;
float:left;
z-index:-1;
}
#slider_container {
width:855px;
height:423px;
overflow:hidden;
}
.bluebar {
width: 855px;
height: 16px;
background-color:#334d5c;
clear:left;
float:left;
}
.menubutton-leftside {
width:60px;
height:20px;
float:left;
margin-top:95px;
}
.menubutton-rightside {
width:60px;
height:20px;
float:left;
margin-top:95px;
text-align:right;
}
h2 {
font-family:Tahoma, Geneva, sans-serif;
font-size:12px;
font-weight:normal;
color:#666;
display:inline;
}
.logo {
width:170px;
height:170px;
float:left;
margin-top:30px;
}
.largemenubutton {
width:261px;
height:259px;
float:left;
clear:left;
}
JSFIDDLE here
http://jsfiddle.net/cX8Z9/
The problem is that there is an extra </div> after the bluebar, so the largemenubutton is not inside the same container mainimage, which is positioned absolutely (so the largemenubutton is just sitting where it would sit if the mainimage hadn't been there at all).
<div class="bluebar"></div></div>
<div class="largemenubutton"><img src="images/portfolio.png" /></div>
And you can't "clear" an absolute positioning the way you can a float.
So the solution is to move the offending </div> two lines down, thus putting the largemenubutton inside the mainmenu.
<div class="bluebar"></div>
<div class="largemenubutton"><img src="images/portfolio.png" /></div>
</div>
See jsFiddle.

Align text in center using css

I used the following code for simple image gallery (actual code found in http://w3schools.com, it works perfectly). After editing css the alignment of text has been changed. I want to align the text at centre. Anybody knows the answer please help me.
My HTML Code:
<html>
<body>
<div id="d">
<div class="img">
<a target="_blank" href="klematis_big.htm">
<img src="a.jpg">
</a>
<div class="desc">
Add a description of the image here </div>
</div>
<div class="img">
<a target="_blank" href="klematis2_big.htm">
<img src="a.jpg">
</a>
<div class="desc">
<p>
Add a description of the image here</p>
</div>
</div>
<div class="img">
<a target="_blank" href="klematis3_big.htm">
<img src="a.jpg">
</a>
<div class="desc">
Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="klematis4_big.htm">
<img src="a.jpg">
</a>
<div class="desc">
<p>
Add a description of the image here</P>
</div>
</div>
<div class="img">
<a target="_blank" href="klematis_big.htm">
<img src="a.jpg">
</a>
<div class="desc">
Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="klematis2_big.htm">
<img src="a.jpg">
</a>
<div class="desc">
Add a description of the image here</div>
</div>
</div>
</body>
</html>
My CSS Code:
#d
{
width : 660;
border:1px;
}
.img
{
margin:3px;
border:1px solid #0000ff;
height:200;
width:200;
float:left;
text-align:center;
}
.img img
{
display:inline;
margin:3px;
border:1px solid #ffffff;
width:100;
height : auto;
}
.img a:hover img
{
border:2px solid #0000ff;
}
.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:2px;
}
Screenshot:
Remove the width of the div.
.desc {
text-align: center;
font-weight: normal;
margin: 2px;
}
And also change it to text-align. The attribute align does not exist.
Try this:
.desc{
margin: 0 auto;
}
you have to modify the value of the margin property:
.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:2px auto;
}
also the hash sign is missing in this part:
<style>
d
{
width : 660;
border:1px;
}
it has to be modified like this:
<style>
#d {
width : 660;
border:1px;
}
Change css to
.desc
{
text-align:center;
font-weight:normal;
width:120px;
margin:2px;
}
change align:center; to text-align:center;
.detail
{
text-align: center;
font-weight: normal;
margin: 0 auto;
}