I am doing a practice because I recently started programming and I have come to areal block in my road, I am not kidding when I said I have been stuck in this part since morning, first with some troublesome images and now this.
Basically I need to move a div that has imgs and some text up so it stays just beneath the "Logo" but it won't budge! I tried to a lot of this but alas to no avail, I even checked it out on firebug and it appears as if the div containing the logo extends beyond what it should but I am positive I didn't mess it up like that.
Also I cannot use ,styles in html or % for this.
<div id="header">
<img src="imgs/logo.png" id="logo" />
<img id="donate" />
<div id="divMenu">
<ul id="menu">
<li>Home</li>
<li> About </li>
<li> Our Programs </li>
<li> Gallery </li>
<li> Contact </li>
<li> Blog </li>
</ul>
</div>
</div>
<div id="bodyLogo">
<img src="imgs/bg-featured.jpg"alt="" />
</div>
<div id="slogan">
<p>As The Saying Goes.. </p>
<p>You Don’t Know What You’ve Got </p>
<p> ‘Till It’s Gone.</p>
<h2>Plant A Tree.</h2>
<h2> Grow A Tree.</h2>
<h2><span id="tituloSpan">Save The Future.</span></h2>
</div>
Here is where it makes a invisible jump I cannot bridge!
<div id="divPictures" class="opacity">
<div class="left">
<img src="imgs/help-out.jpg" alt="">
<p>"TEXT"</p>
<div id="flecha">
<img src="">
</div>
</div>
<div class="right" >
<img src="imgs/what-we-do.jpg" alt="">
<p>"TEXT."</p>
<div id="flecha">
<img src="">
</div>
</div>
</div>
And the CSS:
body{
width: 956px;
font-family: 'Rokkitt', serif;
background: url("../imgs/bg-header.jpg");
background-repeat:repeat-x;
text-decoration: none;
margin: 0 auto;
}
#bodyLogo{
height: 396px;
position: relative;
margin: 18px 0 0 0;
}
#divPictures{
position: absolute;
width: 956px;
background: url("../imgs/bg-body.jpg");
margin: 0 0 700px 0 ;
vertical-align: top;
}
.left{
width: 478px;
float:left;
font-family: 'Quattrocento Sans', sans-serif;
}
.right{
width: 478px;
float:right;
font-family: 'Quattrocento Sans', sans-serif;
}
.left img, .right img{
margin: 0 0 0 10px;
}
#flecha{
background: url("../imgs/arrow-gray.png");
background-repeat: repeat-x;
width: 460px;
}
Thanks A LOT in advance.
Best Wishes.
You have a fixed height on your #bodyLogo which would make it extend past it's size. I don't know how large you have your images, but everything should snap right below it if you remove that height.
Related
I want to do the following:
The biggest Box is a div containing two imgs separated by a small space and with two small block of texts exactly beneath each one.
The problem is that I have been trying (not kidding) for at least 5 hours.
Here is my code:
CSS:
#divPictures {
width: 960px;
position: relative;
float: left;
top: 520px;
left: 200px;
background: url("../imgs/bg-body.jpg");
margin: 0 0 0 -5px;
}
#divPictures img {
margin: 0 0 0 10px;
}
HTML:
<div id="divPictures">
<img src="imgs/help-out.jpg" alt="">
<p>"TEXT HERE</p>
<img src="imgs/what-we-do.jpg" alt="">
<p>"AND HERE"</p>
</div>
EDIT:
I can't post images but is a block containing two images one next to the other and text beneath.
Something like this? Quick example, you can obviously add in extra CSS, or float both left and pad/margin etc...
#divPictures{
width: 100%;
background: url("../imgs/bg-body.jpg");
}
.left{
width: 45%;
float:left;
}
.right{
width: 45%;
float:right;
}
.left img, .right img{
margin: 0 0 0 10px;
}
HTML:
<div id="divPictures">
<div class="left">
<img src="imgs/help-out.jpg" alt="">
<p>"TEXT HERE</p>
</div>
<div class="right">
<img src="imgs/what-we-do.jpg" alt="">
<p>"AND HERE"</p>
</div>
</div>
Make new divs for images and use css atribute display: inline-block to tell interpreter that you want your divs in a line.
<!DOCTYPE html>
<html>
<head>
<!-- CSS -->
<style>
div#pic
{
display: inline-block;
width: 200px;
background: url("../imgs/bg-body.jpg");
margin: 5px 0 0 -5px;
}
div#pic img
{
margin: 0 0 0 10px;
}
</style>
</head>
<!-- HTML -->
<body>
<div id="divPictures">
<div id="pic">
<img src="imgs/help-out.jpg" alt="">
<p>"TEXT HERE"</p>
</div>
<div id="pic">
<img src="imgs/what-we-do.jpg" alt="">
<p>"AND HERE"</p>
</div>
</div>
</body>
</html>
This is the simplest way... When i get stuck I delete it and start over. I think you would have benefitted from starting over...
CSS
<style>
.caption{
text-align: center;
}
li{
background: #ccd2cd;
float: left;
margin:5px;
list-style: none;
padding:5px;
}
</style>
HTML
<ul>
<li>
<img src="http://omarhabash.com/img/feature1.jpg" alt="">
<div class="caption">caption2</div>
</li>
<li>
<img src="http://omarhabash.com/img/feature1.jpg" alt="">
<div class="caption">caption2</div>
</li>
</ul>
if you dont want to use (li) list then just replace those with div classes and rename the style also to the same.
the way i have it here is a good start to a grid if thats what you are aiming for.
http://jsfiddle.net/Mz6aF/
I have a div with some text, then an image underneath the text, whenever you add more text it goes behind the image, (basic example I created in jsfiddle I want it to push the image down just far enough so you can see the text. However I want the two boxes to still be inline, so the images stay consistent, ideally I don't want to just change the height of the div as this text is constantly changing.
<div class="box one">
<div>
<h1>Some text 1</h1>
<p>My paragraph of text is not going to be visible behind the car</p>
</div>
<a href="http://www.google.co.uk">
<img src="http://www.wallpaperswala.com/wp-content/gallery/audi-r8-gt/audi-r8-gt-in-garage.jpg" height="80px" width="150px">
</a>
</div>
<div class="box two">
<div>
<h1>Some text 2</h1>
<p>My paragraph of text is not going to be visible behind the car again!</p>
</div>
<a href="http://www.google.co.uk">
<img src="http://www.wallpaperswala.com/wp-content/gallery/audi-r8-gt/audi-r8-gt-in-garage.jpg" height="80px" width="150px">
</a>
</div>
.box {
color: #333333;
font-size: 12px;
height: 305px;
padding: 10px 15px 0;
width:150px;
}
.box div {
color: #333333;
font-size: 12px;
height: 90px;
padding: 10px 15px 0;
}
.two {
float:right;
margin-top:-310px;
}
Remove height and put min-height: 90px;
.box div {
color: #333333;
font-size: 12px;
padding: 10px 15px 0;
min-height: 90px;
}
http://jsfiddle.net/KApb6/10/
It is happening because you have given height:90px to .box div.
Instead of height, write this 'min-height:90px'.
Here is the fiddle.
So basically you want your text height to stay consistent between all your boxes?
This is quite hard.
One solution is to put every block you have in one row container, like this:
<div class="header">
<div class="one">Some text one</div>
<div class="two">Some text two</div>
</div>
<div class="image">
<div class="one"><img src="image-one.jpg"></div>
<div class="two"><img src="image-two.jpg"></div>
</div>
Or similarly with tables, but it would be hideously hard to maintain all the styles and layout in check.
Other way is just to use javascript to set the height, which is way easier.
Codepen
See this code to know if is the result that you want.
You could put the text in one box and the images in anorther one.
<div class="clearfix">
<div class="box one">
<div>
<h1>Some text 1</h1>
<p>My paragraph of text is not going to be visible behind the car</p>
</div>
</div>
<div class="box two">
<div>
<h1>Some text 2</h1>
<p>My paragraph of text is not going to be visible behind the car again!</p>
</div>
</div>
</div>
<div class="clearfix">
<div class="box one">
<a href="http://www.google.co.uk">
<img src="http://www.wallpaperswala.com/wp-content/gallery/audi-r8-gt/audi-r8-gt-in-garage.jpg" height="80px" width="150px">
</a>
</div>
<div class="box two">
<a href="http://www.google.co.uk">
<img src="http://www.wallpaperswala.com/wp-content/gallery/audi-r8-gt/audi-r8-gt-in-garage.jpg" height="80px" width="150px">
</a>
</div>
</div>
Then in the css remove the height of the div and add the clearfix class:
.box div {
color: #333333;
font-size: 12px;
padding: 10px 15px 0;
}
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
I have floated two elements right in the header of my website which are <div id="twitter"> and <div id ="navbar>, but there appearance becomes skewed when I view them in IE6 and IE7. I believe that I either need to clear the floated elements or apply a clearfix but I am unsure as to where.
here is an image of the issue in IE6 and IE7:
This is the desired result as it would appear in modern browsers.
Here is a link to the web page: http://www.bestcastleintown.co.uk/pg/
CSS:
#twitter {
background: red;
float: right;
height: 40px;
margin-bottom: 40px;
width: 200px;
}
#navbar {
font-size: 2.2em;
float:right;
}
HTML:
<div id="main_header">
<div id="inner_main_header">
<div>
<div id="main_logo">
<div class="home_page_logo left">
<img src="PG_awards_logo.gif">
</div>
</div>
<div>
<div id ="twitter" class="padall">
Follow us
</div>
<div id ="navbar" class="right">
<ul class="nav NG">
<li>home</li>
<li>enter</li>
<li>categories</li>
<li>judging</li>
<li>sponsorship</li>
<li>contact</li>
</ul>
</div>
</div>
</div>
</div>
</div>
Change #navbar style to this:
#navbar{
font-size: 2.2em;
float: right;
width: 60%;
overflow: auto;
}
Just give the #navbar some width and overflow other than visible.
Currently having issues trying to get these bordered text boxed to stay aligned with the above images in a way that when I re-size the page they stick with their prospective images. Currently I have them forced to stick under the images with margin css but once I re-size the boxes, the boxes all flee under the images.
EDIT: Updated code - still having similar issues but this looks more promising - attaching photo of current state.
<body>
<div id="container">
<div id="header">
<img class="leaf" src="images/freshleaf.png" height="150px" alt="freshtext"/>
<!--<button class="navbutton"> <strong> TEST </strong> </button>-->
</div>
<div id="body">
<div id="main" class="">
<div class="column">
<img class="smart" src="images/phone1.png" height="500px" alt="phone1"/>
<div class="box1"> <h3>Pie is tasty Mmmmm...</h3> </div>
</div>
<div class="column">
<img class="smart" src="images/phone2.png" height="500px" alt="phone2"/>
<div class="box2"> <h3>Pie is tasty Mmmmm...</h3> </div>
</div>
<div class="column">
<img class="smart" src="images/phone3.png" height="500px" alt="phone3"/>
<div class="box3"> <h3>Pie is tasty Mmmmm...</h3> </div>
</div>
</div>
</div>
</div>
#body{
text-align: center;
}
#header {
padding-bottom: 50px;
text-align: center;
}
#main{
margin: 0 auto;
text-align:left;
width: 770px;
}
.column{
float:left;
padding-left: 10px;
}
.column:first-child {
padding-left: 0px;
}
.box1{
border: dotted;
border-color: gray;
padding: 2px 5px 2px 5px;
max-width: 250px;
text-align: center;
}
img.smart{
margin-left: auto;
margin-right: auto;
}
wrap each image and the coresponding text in one container and set float:left in the css. get rid of the #textboxes div. then center your #main div by setting it to the width of all the images (plus padding - if desired).
see example fiddle with all the code:
http://jsfiddle.net/QLvt7/4/
I have some Divs floating but for some reason the 3rd DIV doesn't go under the 1st DIV. I can't figure out why? I think it has something to do with the images. When the images are not in, they float fine.
http://jsfiddle.net/xtian/9Je65/
HTML:
<div class="dl-content">
<div class="dl-content-left">
<div class="content-block">
<img src="http://demo.omnigon.com/christian_bovine/SOLIEF/img/thumbs/thumb1.jpg" alt="">
<h4 class="left">The History of Documentation</h4>
<p>The Historical Documentation Exhibit is now open on Ellis! Come view hundreds of...</p>
</div>
<div class="content-block">
<img src="http://demo.omnigon.com/christian_bovine/SOLIEF/img/thumbs/thumb2.jpg" alt="">
<h4 class="left">Rebuilding Ellis One Brick at a Time</h4>
<p>The Historical Documentation Exhibit is now open on Ellis! Come view hundreds of...</p>
</div>
<div class="content-block">
<img src="http://demo.omnigon.com/christian_bovine/SOLIEF/img/thumbs/thumb3.jpg" alt="">
<h4 class="left">Title Number 3</h4>
<p>The Historical Documentation Exhibit is now open on Ellis! Come view hundreds of...</p>
</div>
<div class="content-block">
<img src="http://demo.omnigon.com/christian_bovine/SOLIEF/img/thumbs/thumb3.jpg" alt="">
<h4 class="left">Title Number 4</h4>
<p>The Historical Documentation Exhibit is now open on Ellis! Come view hundreds of...</p>
</div>
</div>
<div class="dl-content-right">
<img src="img/thumbs/ad1.jpg" alt="">
</div>
</div>
CSS:
.dl-content{
width:940px;
margin: 0 auto;
padding: 0 20px;
overflow: hidden;
}
.dl-content-left{
width:618px;
float: left;
}
.dl-content-left .content-block{
width:307px;
float:left;
margin-bottom: 20px;
}
.dl-content-left .content-block img{
width: 139px;
float:left;
margin: 0 8px 0 0;
}
.dl-content-left .content-block p{
float:left;
width:150px;
font-size: 12px;
line-height: 1.4;
}
.dl-content-right{
float:left;
width: 300px;
margin-left: 20px;
}
.dl-content-right img{
width: 300px;
}
I think its to do with the heights of the divs, as a height hasn't been set.
I added a clear div into it, separating the two sets of divs and it works now:
Demo here
You can also set a height on the divs and this would also solve the problem:
Demo here