Wrap DIVs around "double height" image or pull quote - html

I have a grid of image icons in a fluid layout. The icons are broken up by a couple of double-height images. I would like to have the icons wrap around the double height images. For example, if the double height image is the first in the row, the rest of the icons fill the rest of the row, then wrap down and fill in next to the double height image and complete the next row.
If I just put them all in a list together, what happens is that once the row is filled in, it wraps below the double height image, effectively leaving a big white space to the right of the double height image.
The other double height image is the seventh item in the list (the first double height image, then 5 single height icons, then the next double height image). I would like the single height images to wrap around this one as well without leaving a blank row on the bottom right of the image. Ideally, I'd like to stick this image on the right, but wasn't able to get that to work.
You can see the page here:
http://www.kandlekidswear.com/Pages/designs.html
Right now, my workaround is that I have put two single height divs within a double height divs, so the list is effectively a list of double-height divs. It is working ok, but the issue is that it leaves a large two-row white space at the bottom right. I would welcome an alternate approach. Thanks in advance!
CSS
.singleHeight {
width: 180px;
height: 180px;
float: left;
margin: 10px;
}
.doubleHeight {
width: 200px;
height: 400px;
float: left;
margin: 5px;
}
HTML
<div class="doubleHeight">
<img src="doubleHeightImage1.jpg">
</div>
<div class="doubleHeight">
<div class="singleHeight"><img src="icon1.gif"></div>
<div class="singleHeight"><img src="icon2.gif"></div>
</div>
<div class="doubleHeight">
<div class="singleHeight"><img src="icon3.gif"></div>
<div class="singleHeight"><img src="icon4.gif"></div>
</div>
...
<div class="doubleHeight">
<img src="doubleHeightImage2.jpg">
</div>
<div class="doubleHeight">
<div class="singleHeight"><img src="icon5.gif"></div>
<div class="singleHeight"><img src="icon6.gif"></div>
</div>
...

Related

how to left align many rows of inline divs, that together are centered in the screen (regardless of screen size)

I have several inline divs, inside a table cell, that are all left aligned, and will wrap to the next row when there is no more space. For the most part, they look pretty good, and rearrange to properly fill the screen.
The problem is when the width of the screen is JUST SHY OF the size necessary to fit another element on the right. There is a big gap on the right side of the screen, compared to the left. It's a stylistic choice, but I am trying to figure out a way to balance the margins on both sides, no matter what the screen size is. Here is my site as it looks currently: www.bradthedesigner.com
I am trying to get something that allows each individually to be left aligned, in a group that is centered. Instead I can either get everything left aligned (but the extra space at right looks bad, especially on small screens), or everything centered (which looks bad when there is only one item on the bottom row).
HTML
<center>
<div class="container">
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
<div class="outerelement">
<div class="element"></div>
</div>
</div>
</center>
CSS
.container
{
text-align:center;
border:2px solid black;
}
.outerelement
{
width:216px;
height:216px;
display: inline-block;
}
.element
{
background-color:#999999;
width: 200px;
height: 200px;
border-radius:16px;
}
Looking at the code I've got online, I see that I switched to tables, because I was more familiar with their behavior and borders for debugging. Here is me recreating my results with divs though... I've tried using <center> outside, align=center inside, and all sorts of CSS styles that came up on other searches through stack overflow.
I've been beating my head against a wall, and can't seem to find any-one doing something similar. It doesn't seem too crazy does it? Basically it boils down to, if the contents of a div are too big to fit, of course it should wrap... but why then does the div stay the width of the screen if the contents that fit on any row don't reach that far? A table with rows and columns would work, but that isn't able to adapt to different screen resolutions or window re-sizing, is it?
Well from the image you are posting I can tell the problem ...
You want to whole block that contain the small blocks to be horizontally aligned (equal spaces on each side) and the inline divs to be aligned to the left ...
Your first attempt is the default behavior (the inline blocks are wrapping to the next line but no proper alignment for the container)
Your second attempt was to set text-align: center to the container which is perfect but it won't align the last line as you desire ...
To achieve what you want, you need to wrap all the inline divs in a single div with predefined width ... Something like
.wrapper-div {
width: 500px;
margin: 0 auto;
}
The margin: 0 auto declaration will force the div to be horizontally aligned as you want.
When you render out the blocks, render out empty placeholders that aren't visible but take up the space of the missing elements on the last row. This will push the existing elements on the last row to the left.

<div> fails to fill the page background properly

I have a <div> positioning issue on single-page web design. To be more specific — I can't find a way to fill the background properly, using the <div>s.
For some reason, the <div>s won't fill the background as I want — the background always stays visible (on left/right and top/bottom sides of the <div>s).
What I'm trying to achieve:
My entire page is a single-page website. The page is composed of 5 rectangle <div>s, "touching" each other in a vertical fashion (0 pixels of background between them). I don't want the background to be visible at any part of the page.
I want the top <div> to fill the upper part of the screen ("touch" the browser's upper menu) and the right/left sides.
I want each one of the 3 middle <div>s to "touch" the left and right sides of the screen (and of course touch the two <div>s above and below, without any space between them [no background seen]).
I want the bottom <div> to fill the lower part of the screen ("touch" the browser's lower menu) and the right/left sides.
I've tried to change the position value on the CSS part. The outcome was always a "twisted" version of the page.
My HTML code:
<div id="page1" align="center">
<a id="about"></a>
</div>
<div id="page2">
<a id="portfolio"></a>
</div>
<div id="page3">
<a id="Dream"></a>
</div>
<div id="page4">
<a id="contact"></a>
</div>
<div id="page5">
<a id="Love"></a>
</div>
My CSS code:
#page1{
height : 1000px;
background-color: #4c3719;
}
#page2{
height : 1000px;
background-color: #9a8479;
}
#page3{
height : 1000px;
background-color: #ddbad8;
}
#page4{
height : 1000px;
background-color: #ddd28d;
}
#page5{
height : 1000px;
background-color: #ed9aa9;
}
Write before all CSS code this
* {
margin:0;
padding:0
}
If I correctly understand this may help

expand two divs similar to the divs in wordpress dashboard

I have two divs on a page with the same height position. I'm trying to make them expandable, allot like what goes on in the WordPress dashboard area:
Now i've got the left div to expand but only with the right div staying at the same width. I need both to expand on zooming in and out.
any ideas how this is done?
I've been looking it up for the past hour but i cant find anything.
A link to a tutorial would be cool (good luck finding one).
EDIT:
Here guys, i found something similar: http://jsfiddle.net/Khez/2zLPF/embedded/result/
do you see how the two divs side by side expand? the green and blue ones...
If you want your divs to dynamically change depending on the width of their container, set the widths using percentages:
HTML:
<div class="column">
<div class="wrapper">
<p>Text</p>
</div>
</div>
<div class="column">
<div class="wrapper">
<p>Text</p>
</div>
</div>
CSS:
.column {
float: left;
width: 50%; }
.column div { margin: 0 20px; /* Set the spacing between the cells */ }
Preview: http://jsfiddle.net/Wexcode/F7h2C/
NOTE: Because you are setting the combined widths of the columns to 100%, you cannot add padding to .column if you want them to be on the same line. The inner div wrapper will allow you to add spacing between your two columns. You should apply all background attributes to .wrapper.

Adding side by side divs confusion

I always seems to get this simple HTML stuff wrong. I am currently trying to add side by side divs in the middle of a page on this test page I made:
http://www.comehike.com/hiking_dev.php
The code I added was something like this:
<div style="width: 460px; float: left; ">
<strong>Test hello</strong>
</div>
<div style="width: 300px; float: right; ">
<strong>Test hello 2</strong>
</div>
I added <strong> tags so you can spot it on the page better.
But do you see there is text that appears there that reads like this "When considering the injury risk of any" - but that text is in the <p> tag below. Why is it appearing there?
Is it better practice to wrap my 2 divs that I am trying to align, within another div?
After your two floating divs, add another empty div...
<div style="clear:both;"></div>
This will cause the two floating divs to push all subsequent content below them. As you have it now, there is 200 pixels of empty space after the first div allowing the other content to simply wrap around it.
Increasing the width of the floating divs may not be desirable for your layout so clear:both; is most typical for this situation.
Surround those two divs in a parent div with overflow set to hidden.
<div style="overflow:hidden;">
<div style="width: 460px; float: left; ">
<strong>Test hello</strong>
</div>
<div style="width: 300px; float: right; ">
<strong>Test hello 2</strong>
</div>
</div>
An alternative (as others have pointed out) is to use a third element:
<div style="clear:both;"></div>
It's debatable as to which is better. Usually, either is just fine. Here's a post about the topic:
Floated Child Elements: overflow:hidden or clear:both?
You'll either need to add a div below your two divs with clear:both; as others have suggested, or you could add clear:both; to the following <p> element.
Because you have an entire page width of 960px. You're combined div widths are 760px (400+300). If you add 200px to the second div you should be fine.
Edit: Because of padding, you can increase either of the divs by 150px and be fine.

Floating div's with images and variable length text

I am having an issues getting my HTML to format the way i need it too.
I am creating div dynamically (parent). In each div there are two divs inside (div one & two).
Div one is text that can be any length or variable length. Div two contains an image.
Regardless of the size of the parent div, the text needs to fill as much width as possible. But i need the 2nd div with the image, to float above the text right at the end of the line. I also need all the image divs, to vertically line up.
This parent div is re-sizable and can get either smaller of bigger but the floating image must always be sitting in the sentence line but on the right of the container.
If the text is wider than the div parent, the image needs to float against right hand side of the parent container on the same line as the text. If the text is smaller than the parent the image must still be on the right hand side of the parent div.
Think of it as a floating image full stop, if that makes sense. where every sentence has its full stop in one long vertical line.
I have tried both divs and tables but am getting garbled results.
Here is my current code:
<div>
<div style="display: inline; float: left;">
Text Goes here</div>
<div style="display: inline; float: right; z-index: 1000;">
<img src="info.png" /></div>
</div>
<div>
<div style="display: inline; float: left;">
Next line of Text Goes here</div>
<div style="display: inline; float: right; z-index: 1000;">
<img src="info.png" /></div>
</div>
Thanks
I think it's a bit hard to visualize what result you're trying to get. Can you draw a diagram that illustrates your desired results?
As best I can tell, you're looking for this (view results at JSFiddle): http://jsfiddle.net/kcschaefer/GYQea/9/
Code is:
<div id="parent" style="width: 100%;">
<div>
First text goes here
<img src="http://www.kendraschaefer.com/images/info.png" style="float:right; z-index: 1000;" />
<div>
<div style="clear: both;"></div>
<div>
Next line of really long text that demonstrates how the float will work would go right here, and you can see that the info thingie goes all the way to the end of the div, no matter how long this is.
<img src="http://www.kendraschaefer.com/images/info.png" style="float:right; z-index: 1000;" />
<div>
</div><!-- end parent -->