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>
Related
So this is my markup, it's basically an image gallery.
<div class="img">
<div class="cont"><img src="logo.jpg" alt="logo" /></div>
<div class="desc">This is the awesome logo</div>
</div>
<div class="img">
<div class="cont"><img src="logo.jpg" alt="logo" /></div>
<div class="desc">This is the awesome logo</div>
</div>
<div class="img">
<div class="cont"><img src="logo.jpg" alt="logo" /></div>
<div class="desc">This is the awesome logo</div>
</div>
<div class="img">
<div class="cont"><img src="logo.jpg" alt="logo" /></div>
<div class="desc">This is the awesome logo</div>
</div>
And here's my CSS
div.img {position:relative;
margin:5px;
border:1px solid #000;
padding:0;
width:300px;
height:300px;
float:left;
}
div.cont {
position:absolute;
left:50%;
margin-left:-125px;
}
div.img img {
margin-top:5px;
border:1px solid white;
padding:0;
width:250px;
height:250px;
}
div.desc {
text-align:center;
color:black;
}
div.img a:hover img {
border:1px solid #666;
}
Basically my problem is I want the "img" element to behave as if it's in the normal flow, so that my "desc" div can acknowledge it as a block-level element and position itself below the image (which is a logo, by the way) exactly the way I want it, I know that absolute-positioned elements are taken away from the normal document flow, that's why my "desc" div is behind the image because it behaves as if the "img" element isn't there at all, which is not what I want.
I know this can be solved by changing the "cont" div to position-relative, but I want answers for position-absolute only because I feel like it's really important to tackle this specific problem and the specific situation, thanks.
try it DEMO
div.img {position:relative; margin:5px; border:1px solid #000; padding:0; width:300px; height:300px; float:left; text-align:center; }
/*div.cont {position:absolute; left:50%; margin-left:-125px;}*/
div.img img {margin-top:5px; border:1px solid white; padding:0; width:250px; height:250px;}
div.desc {text-align:center; color:black;}
div.img a:hover img {border:1px solid #666;}
How about positioning the desc div by giving it bottom 0; position:absolute;
Demo: http://jsfiddle.net/lotusgodkk/GCu2D/360/
CSS:
div.desc {
text-align:center;
color:black;
position:absolute;
bottom:10px; //Can be any value depending on your design.
}
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.
I am creating a code for my web programming class. I'm having troubles having my DIV tags to line up. I'm needing them to be equal, and no matter what I do I can't get them to work. The .black and .grey are the same part, and I'm not sure how to make it so they are even.
.css
.main {
background-color:#e3e2e2;
margin-bottom:1em;
padding:10px;
margin-left:auto;
margin-right:auto;
text-align:center;
margin:93%;
border-radius:20px;
float:left;
margin:20px;
}
.bg1 {
background-color:#d2cdc8;
border-top-left-radius:20px;
border-bottom-left-radius:20px;
width:65%;
float:left;
}
.bg2 {
background-color:#a79f97;
border-top-right-radius:20px;
width:35%;
float:right;
}
.bg3 {
background-color:#a79f97;
border-bottom-right-radius:20px;
width:35%;
float:right;
}
.black {
background-color:#3e3831;
margin-left:10px;
margin-right:10px;
text-align:center;
width:92%;
border-top-left-radius:20px;
border-top-right-radius:20px;
float:right;
margin-top:20px;
margin-right:20px;
margin-left:20px;
color:#d6d3c6;
font-family: TF2Build;
}
.grey {
background-color:#514840;
margin-left:10px;
margin-right:10px;
text-align:center;
width:92%;
border-bottom-left-radius:20px;
border-bottom-right-radius:20px;
float:right;
margin-bottom:20px;
margin-right:20px;
margin-left:20px;
color:#aba9a8;
}
.html
<div class="bg1">
<div class="main">
<p></p>
</div>
</div>
<div class="bg2">
<div class="black">
<p>Test</p>
</div>
</div>
<div class="bg3">
<div class="grey">
<p>Test</p>
</div>
</div>
Js Fiddle:
http://jsfiddle.net/W4Xb3/1/
I made some changes to your HTML, wrapping it in a "table" div and display the children as tablecells. (dropping .bg3, since it isn't needed)
HTML:
<div class="wrap">
<div class="bg1">
<div class="main">
...
</div>
</div>
<div class="bg2">
<div class="black">
...
</div>
<div class="grey">
...
</div>
</div>
</div>
CSS:
.wrap {
display: table;
width: 100%;
}
.bg1 {
display: table-cell;
vertical-align: top;
}
.bg2 {
width:35%;
display: table-cell;
vertical-align: top;
}
And the updated Fiddle.
You're fighting issues with borders/margins/padding modifying the height/width. IE before v9 used border-box as default, all other browsers and new versions of IE use content-box. The only time I'll admit IE made things easier:
http://www.w3schools.com/cssref/css3_pr_box-sizing.asp
Try border-box on everything then readjust your height/width values.
I use the following to display an image on the left side and any related info on the right side of the image. In some cases where description, address and other info exceed the height of the image, the text goes below the image. My question is how should I keep the text for not going under the image, but to continue like a column?
.eventphoto
{
padding:1px;
width:200px;
float:left;
margin-right:15px;
border-radius:2px;
}
.desc
{
font-size:0.8em;
line-height:13pt;
}
<div class="desc">
<img class="eventphoto" src="">
<div style="float:left;">
<p>DESCRIPTION</p>
.
.
.
</div>
</div>
This is a fairly-standard construct: the media object
In your case, if we add Nicole's styles like so:
<style>
.eventphoto
{
padding:1px;
width:200px;
margin-right:15px;
border-radius:2px;
}
.desc
{
font-size:0.8em;
line-height:13pt;
}
.media {margin:10px;}
.media, .bd {overflow:hidden; _overflow:visible; zoom:1;}
.media .img {float:left; margin-right: 10px;}
.media .img img{display:block;}
.media .imgExt{float:right; margin-left: 10px;}
</style>
(leaving the formatting to your original classes), and add a wrapper around the image with the appropriate styles:
<div class="desc media">
<div class="img">
<img class="eventphoto" src="http://placekitten.com/100/100">
</div>
<div class="bd">
<p>DESCRIPTION</p>
<p> ... </p>
</div>
</div>
All works well. See this CodePen for an example: http://codepen.io/paulroub/pen/JDsKa
Try float:left on the image and float:right on the text like:
.eventphoto
{
padding:1px;
width:200px;
float:left;
margin-right:15px;
border-radius:2px;
}
.desc
{
font-size:0.8em;
line-height:13pt;
float:right;
}
I think overflow: hidden; is your best bet. Here's a demo of it in use:
http://jsbin.com/owesiw/1/edit
i have div's wrapped under div's my html code is.
<div id="content-row">
<div id="left-box">
<div id="small-box">
</div>
<div id="small-box">
</div>
<div id="small-box">
</div>
<div id="small-box">
</div>
</div>
</div>
and my css is
/*content-row*/
#content-row {
margin: 0 auto!important;
padding-left:50px;
width:990px;
height:320px;
padding-bottom:20px;
}
#left-box {
float:left;
width:360px;
height:340px;
}
#small-box {
width:160px;
height:150px;
background-color:#fff;
float:left;
margin:0px 20px 20px 0px;
}
the above style sheet is exclusively for ie6. my problem is the left-box is taking an extra 20px at the right side. when i have defined the left-box to be 360px; it it taking as 380px;
here is the link to the full code.
http://jsfiddle.net/HXGsT/
what is wrong with the code?
It's a known bg in IE6, see this page for more information:
http://www.positioniseverything.net/explorer/doubled-margin.html
Basically, the quick fix is to also add display: inline; to the floating element.
In response to your comment:
<div class="content-row">
<div id="left-box">
<div class="small-box">
</div>
<div class="small-box">
</div>
<div class="small-box">
</div>
<div class="small-box">
</div>
</div>
</div>
.content-row {
margin: 0 auto!important;
padding-left:50px;
width:990px;
height:320px;
padding-bottom:20px;
}
#left-box {
float:left;
width:360px;
height:340px;
}
.small-box {
width:160px;
height:150px;
background-color:#fff;
float:left;
margin:0px 20px 20px 0px;
}
The id #left-box can be an ID as there is only one of these elements with id="left-box" in the document, but because the others are repeated, they must be defined with classes :)