I only need one column on my index page and I want it to be on the right side of the screen. I am using a background image that has what I want on the left. bg-image is in the body
I am trying this approach but it is not getting all the way to the right. Am I going about this wrong and more generally how do you position one column to the right of the screen?
<div style=" float:right" >
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
<div class="four"></div>
</div>
css for the four inner divs
body{
background-image: url(images/splashpage.jpg);
background-position:top;
font-family: Arial, Helvetica, sans-serif;
}
.one{
<!-- width:40%; -->
background-color:lightblue;
font-family: Arial, Helvetica, sans-serif;
position:relative;
<!-- left:150px; -->
}
.two{
width:580px;
background-color:lightgreen;
position:relative;
right:100px;
top:50px;
}
.three{
width:600px;
background-color:blue;
position:relative;
right:100px;
}
.four{
width:580px;
position:relative;
left:20px;
margin: 0 auto;
top:50px;
}
.footer{
width:580px;
text-align:center;
position:relative;
top:50px;
this was working fine for the containing div to float right, but all this was doing was putting the inner divs side by side and I need them to stack.
<div style=" float:right" class="container" >
<div class="one" style="float:right"></div>
<div class="two" style="float:right"></div>
<div class="three" style="float:right"></div>
<div class="four" style="float:right"></div>
</div>
so I put a clear div in between each and now the container div floats right as well as the inner divs while stacking. It seems simple now but maybe if someone else has this problem this will help.
<div style=" float:right" class="container" >
<div class="one" style="float:right"></div>
<div style="clear:both"></div>
<div class="two" style="float:right"></div>
<div style="clear:both"></div>
<div class="three" style="float:right"></div>
<div style="clear:both"></div>
<div class="four" style="float:right"></div>
</div>
not sure if its best practice or if there's a more efficient way but it works.
Related
I'm trying to make something like this. Any help will be greatly appreciated.
(can't paste the image due to 2 missing points of reputation ;) ) http://i.stack.imgur.com/p7xhr.jpg
I'm sorry I've given an impression like I don't know what I'm doing at all and I want someone else to do my work for me. I did try various solutions none of which seems to work.
on jfsfiddle it seems to work, but when I check on the actual site the top right image gets moved to another row
http://jsfiddle.net/37GAn/1/
html
<div>
<div class="image">
<img src="image.jpg" width="98" height="203"/>
</div>
<div class="image">
<img src="image.jpg" width="85" height="203"/>
</div>
<div class="clear"></div>
</div>
<div>
<div class="image">
<img src="image.jpg" width="130" height="210"/>
</div>
<div class="image">
<img src="image.jpg" width="69" height="197"/>
</div>
<div class="clear"></div>
</div>
css
.image {
float: left;
width: 100px;
margin-top:50px;
margin-left:280px;
}
This is just to give you a round-about idea.
You'll need your HTML as such:
<div id="contentHolder">
<div class="row">
<div>
<div class="image"></div>
<div class="textHolder">Some text here</div>
</div>
<div>
<div class="image"></div>
<div class="textHolder">Some text here</div>
</div>
</div>
<div class="row">
<div>
<div class="image"></div>
<div class="textHolder">Some text here</div>
</div>
<div>
<div class="image"></div>
<div class="textHolder">Some text here</div>
</div>
</div>
</div>
and CSS as such:
* {
margin:0;
padding:0;
}
#contentHolder {
background-color:Gray;
height:100%;
padding:40px 10px;
}
.row {
height:250px;
width:100%;
margin-bottom:30px;
}
.row > div {
display:inline-block;
width:48%;
height:inherit;
vertical-align:top;
}
.image {
background:white url(http://cdn.sstatic.net/stackoverflowmeta/img/apple-touch-icon.png) no-repeat 0px 0px scroll;
height:160px;
width:70%;
margin:20px auto;
border-radius:10px;
}
.textHolder {
color:White;
width:50%;
height:20px;
margin:0 auto;
}
This should work for you. This may still need some work as I have not tried to make it inch-perfect. That I'll leave it to you!!! :)
You can see that here:http://jsfiddle.net/a7zLW/
Hope this helps!!!
I'm learning basic HTML 5 and CSS by myself, and I've been using div instead of table as recommended by many bloggers and web developers. But now I'm with this question:
I'm trying to make a table looks like this:
(source: webdesign-gm.co.uk)
Using this code:
CSS
.table {
font-size:14px;
border-style:solid;
border-width:2px;
margin:0;
padding:3px;
text-align:center;
vertical-align:middle;
display:table-cell;
font-family:Verdana, Geneva, sans-serif;
font-weight:bold;}
HTML
<div align="center">
<div id="row1">
<div class="table" style="min-width:500px;max-width:500px;">Random Number: <?php echo $gRandNum; ?></div>
</div>
<div id="row2" style="min-height:140px;">
<div id="row2column1" style="float:left;">
<div id="row2column1row1">
<div class="table" style="border-top-style:none;border-right-style:none;min-width:150px;">test1</div>
</div>
<div id="row2column1row2">
<div class="table" style="border-top-style:none;border-right-style:none;min-width:150px;">test2</div>
</div>
</div>
<div class="table" style="border-top-style:none;min-width:350px;">
test3<br>test3<br>test3<br>test3<br>test3<br>test3
</div>
</div>
<div id="row3" style="width:500px;">
<div class="table" style="min-width:500px;max-width:500px;border-top-style:none;">teste</div>
</div>
http://jsfiddle.net/XxRJe/2/
The row2 was supposed to have 2 columns inside of it. And the first column divided in another 2 rows, and each row would have 50% of the row2 height. But that is what is not happening. How do I fix it?
Basically, I want two columns, and the first divided in 2 rows, but I have no idea on how to set it.
Hi check this code i tried to fix your problem http://jsfiddle.net/XxRJe/13/. To handle heights on divs with % you need to be carefull because to make it work all his parents need to have a height on % or px to set it.
Here the css
.table {
font-size:14px;
border-style:solid;
border-width:2px;
text-align:center;
font-family:Verdana, Geneva, sans-serif;
font-weight:bold;
}
#row2 {
height:300px;
width:500px;
}
#row2column1, #row2column2 {
width:50%;
height:100%;
color:#fff;
background-color:#000;
}
#row2column1 .celd{
height:50%;
background-color:#666;
}
and HTML
<div>
<div id="row1">
<div class="table" style="min-width:500px;max-width:500px;">Random Number:<?php echo $gRandNum; ?></div>
</div>
<div id="row2" style="min-height:140px;">
<div id="row2column1" style="float:left;margin:auto;">
<div id="row2column1row1" class="celd">
<div class="celd">test1</div>
</div>
<div id="row2column1row2" class="celd">
<div class="celd">test2</div>
</div>
</div>
<div id="row2column2" style="float:right">
test3<br>test3<br>test3<br>test3<br>test3<br>test3
</div>
</div>
<div id="row3" style="width:500px;">
<div class="table" style="min-width:500px;max-width:500px;border-top-style:none;">teste</div>
</div>
</div>
If you need some more complex elements you have to play with % an dinamic heights.
An additional tip donĀ“t set styles inline make it all in the css file
Below is my code :
<div id="footer">
<div id="left_footer">
<div id="img_left" align="center">
<img src="separator_bar.jpg" align="middle"/>
</div>
</div>
<div id="right_footer">
<div id="img_right" align="center">
<img src="separator_bar.jpg" align="middle"/>
</div>
</div>
</div
CSS:
#footer {
width:500px;
position:relative
}
#left_footer{
float:left;
}
#right_footer{
float:right;
}
I am trying this code but my image is not aligned to center its always aligned to left in left footer and to right in right footer. Please suggest !
I would approach the layout like this:
http://jsfiddle.net/yWmZ5/1/
HTML
<div id="footer">
<div id="left_footer">
<img src="http://placekitten.com/100/100" />
</div>
<div id="right_footer">
<img src="http://placekitten.com/100/100" />
</div>
</div>
CSS
#footer { width:500px; position:relative; overflow:hidden; }
#left_footer{ width:250px; float:left; text-align:center; background:orange; }
#right_footer{ width:250px; float:right; text-align:center; background:yellow; }
Make sure you strip all styling (eg - align, etc) out of your HTML and put it in your CSS.
Try this style:
#footer > div{width:50%}
your div#left_footer and div#right_footer need to have some width, in order to display the content in the middle
change your corresponding css to this:
#left_footer{
text-align:center;
float:left;
width:50%;
}
#right_footer{
float:right;
width:50%;
}
see this fiddle
I've had page layout made via an Html table in my home page.
the lay out was fine , though i was reading that tables are not the way to go (SEO and maybe not only that)
so i need to use divs, the layout is as follows
(i am in RTL Lang /style /direction)
My Question is
Could anyone Try and simplify how to or give an example for a lay out like that
and in more detailed explained :
i think "my life" was so simple, when i had to understand the structure of a table
so, for illustration purpose take this markup:
<table>
<tr> <td>1</td> <td>2</td> </tr>
<tr> <td>3</td> <td>4</td> </tr>
</table>
here you don't need to think much to analyze that this will be 2 by 2 table
but when it comes to divs i get no results laying them as i plan to
i would like to know how do i make that simple as it was with a table for me .
2 now that i am trying to achieve that layout via divs (no table involved )
and to make it work so that layout will be Cross Browser, meaning will look same
at least for the 3 main browsers IE8&9 / FF / Chrome (only my preference)
thanks in advance
I tried hard to make template like what you want.I hope you will like it.See my layout
by division tag.I am attaching a screen shot as well that is created on the base of
my div logic.I think it will be clear for you.
<div id="main" >
<div style="background-color:Blue; text-align:center; ">
Main banner
</div>
<div style="background-color:Green; text-align:center; " >
Top menu
</div>
<div style="background-color:Gray; text-align:center; width:300px; float:right; height:200px; " >
Right side menu
</div>
<div style="background-color:Red; text-align:center; height:200px;" >
<div style="background-color:Fuchsia; text-align:center; width:300px; float:right; height:100px; ">
contend2
</div>
<div style="background-color:Lime; text-align:center;height:100px; ">
contend1
</div>
<div style="background-color:Aqua; text-align:center; width:300px; float:right; height:100px; ">
contend4
</div>
<div style="background-color:Orange; text-align:center;height:100px; ">
contend3
</div>
</div>
<div style="background-color:Silver; text-align:center; " >
Footer
</div>
</div>
**In case if you want external css then use**
<div id="main" >
<div id="mainbanner">
Main banner
</div>
<div id="topmenu" >
Top menu
</div>
<div id="rsm" >
Right side menu
</div>
<div id="maincontend" >
<div id="c2" >
contend2
</div>
<div id="c1">
contend1
</div>
<div id="c4">
contend4
</div>
<div id="c3">
contend3
</div>
</div>
<div id="footer">
Footer
</div>
</div>
**CSS................**
#Main
{
}
#mainbanner
{
background-color:Blue;
text-align:center;
}
#topmenu
{
background-color:Green;
text-align:center;
}
#rsm
{
background-color:Gray;
text-align:center;
width:300px;
float:right;
height:200px;
}
#maincontend
{
background-color:Red;
text-align:center;
height:200px;
}
#c2
{
background-color:Fuchsia;
text-align:center;
width:300px;
float:right;
height:100px;
}
#c1
{
background-color:Lime;
text-align:center;
height:100px;
}
#c4
{
background-color:Aqua;
text-align:center;
width:300px;
float:right;
height:100px;
}
#c3
{
background-color:Orange;
text-align:center;
height:100px;
}
#footer
{
background-color:Silver;
text-align:center;
}
You can't ask for complete layouts, but I wrote two tutorials that will definitely help you acquire the skill required to make them: How to Position in CSS and Create a Fixed ('Sticky') Footer with CSS.
Check this
<div id="wrapper">
<div id="header">
<p>This is the Header</p>
</div>
<div id="navigation">
<p>This is the Menu</p>
</div>
<div id="leftcolumn">
<div class="row">
<div>1st block</div>
<div>2nd block</div>
</div>
<div class="row">
<div>3rd block</div>
<div>4th block</div>
</div>
</div>
<div id="rightcolumn">
sfsf
</div>
<div id="footer">
<p>This is the Footer</p>
</div>
</div>
DEMO
HTML-Cleaner has a nice feature to replace HTML tables with DIVs: http://www.html-cleaner.com/features/replace-html-table-tags-with-divs/
Make sure you include the css code supplied.
http://denartcc.org/images/help.jpg
As you can see from the arrows in my attached picture, I'm trying to slide those four divs (Who's Online, Upcoming Events, Statistics, and Weather) UP to fill the void. The column on the right has a variable height, and when it expands, those four aforementioned divs continue to move down the page. They need to stay underneath the white box.
The problem with absolute positioning is that the four divs (Who's Online, Upcoming Events, etc.) will also have variable heights, so I don't want to stick the second row of those in an absolute position.
HTML
<div id="TopContentWrapper">
<div id="phototicker">
<jdoc:include type="modules" name="phototicker" />
</div>
<div class="RightSide">
<div class="rtsidemod">
<div class="rtsidetitle">Control Panel</div>
<div class="rtsidecontent"><jdoc:include type="modules" name="controlpanel" /></div>
</div>
<div class="rtsidemod">
<div class="rtsidetitle">Newletter</div>
<div class="rtsidecontent"><jdoc:include type="modules" name="newsletter" /></div>
</div>
<div class="rtsidemod">
<div class="rtsidetitle">Event Notifications</div>
<div class="rtsidecontent"><jdoc:include type="modules" name="eventnotifications" />Check Check</div>
</div>
<div class="rtsidead">
<img src="http://denartcc.org/dev/templates/NexGenDEN/images/ads/forum.png"></img>
</div>
<div class="rtsidead">
<img src="http://denartcc.org/dev/templates/NexGenDEN/images/ads/ts.png"></img>
</div>
<div class="rtsidead">
<img src="http://denartcc.org/dev/templates/NexGenDEN/images/ads/ts.png"></img>
</div>
</div>
<div class="midbox1">
<div class="modbox">
<div class="modtitle">Who's Online
</div>
<div class="mid1">
<p class="mid"><jdoc:include type="modules" name="whosonline" /></p>
</div>
</div>
<div class="modbox">
<div class="modtitle">Upcoming Events
</div>
<div class="mid2">
<p class="mid"><jdoc:include type="modules" name="upcomingevents" /></p>
</div>
</div>
</div>
<div class="midbox2">
<div class="modbox">
<div class="modtitle">Statistics
</div>
<div class="mid1">
<p class="mid"><jdoc:include type="modules" name="statistics" /></p>
</div>
</div>
<div class="modbox">
<div class="modtitle">Weather
</div>
<div class="mid2">
<p class="mid"><jdoc:include type="modules" name="weather" /></p>
</div>
</div>
</div>
</div>
CSS
#TopContentWrapper {
width:920px;
margin:0 auto;
position:relative;
}
div.RightSide {
width:255px;
float:left;
margin-left:5px;
}
div.rtsidemod {
float:left;
width:100%;
padding-bottom:5px;
background-image:url(../images/rightbg.png);
background-repeat:repeat-y repeat-x;
}
div.rtsidetitle{
font-weight:bold;
color:white;
font-size:12px;
background-image:url(../images/rttitlebg.png);
background-position:top left;
height:15px;
}
div.rtsidetitle:hover {
background-position:bottom left;
}
div.rtsidecontent {
font-size:11px;
color:white;
}
div.rtsidead {
width:255px;
float:left;
margin:5px 0 0 0px;
border:1px solid black;
}
div.modtitle {
width:322px;
height:15px;
font-size:12px;
color:white;
font-weight:bold;
background:url(../images/midmodbg.jpg);
background-repeat:repeat-x;
}
div.mid1 {
display:block;
float:left;
background-image:url(../images/midmodcontentbg.png);
background-repeat:repeat-both;
width:320px;
border:1px solid black;
border-top:none;
height:70px
}
div.mid2 {
display:block;
float:left;
background-image:url(../images/midmodcontentbg.png);
background-repeat:repeat-both;
width:320px;
border:1px solid black;
border-top:none;
height:70px
}
div.modbox {
float:left;
width:310px;
margin-right:19px;
margin-top:5px;
}
div.midbox1 {
float:left;
width:660px;
margin:0px 0 0px 5px;
padding:0;
}
div.midbox2 {
float:left;
width:700px;
margin:0px 0 0px 5px;
padding:0;
}
Rearrange your divs to be in 2 columns rather than 4 quadrants. You currently have:
<div id="phototicker">
...
</div>
<div class="RightSide">
...
</div>
<div class="midbox1">
...
</div>
<div class="midbox2">
...
</div>
Instead, arrange them like this:
<div class="LeftSide">
<div id="phototicker">
...
</div>
<div class="midbox1">
...
</div>
<div class="midbox2">
...
</div>
</div>
<div class="RightSide">
...
</div>
That way, the midboxes will naturally flow under the phototicker. You will need to have a specific width on the right and left side divs and then just float the both left.