CSS alignment on my webpage between two elements - html

I have two elements on my page which I wish to align side by side, what would be the best way of going about this, and can somebody explain the best way to go about coding it when you want to align elements together.
In this example I want the video to take up most of the room say 3/4 and the chart to be in the remaining 1/4. (Bootstrap is loaded on this page)
Any suggestions?
This is what it currently looks like:
http://i1057.photobucket.com/albums/t390/Alexwileyy/element_zps066ecdd2.png
(I have outlined the video in a color so I can see the perimeters)
This is my HTML code for the two elements:
<!--Video Section-->
<div class="video">
<div class="container">
<div class="video-element">
<iframe width="460" height="215" src="//www.youtube.com/embed/PdABTJhRTLY" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
<!--End Of Video Section-->
<!--Start of chart-->
<div class="container">
<div class="chart">
<div class="chart-cont">
<h1 id="chart-header">Charts</h1>
</div>
<div class="chart-cont">
<h1>1</h1>
<img src="http://www.spotlightreport.net/wp-content/uploads/2013/06/gran-tourismo-6-banner-3.jpg">
View Review</td>
</div>
<div class="chart-cont">
<h1>2</h1>
<img src="http://savegameonline.com/wp-content/uploads/2013/05/CoD-Ghosts-banner.png">
View Review</td>
</div>
<div class="chart-cont">
<h1>3</h1>
<img src="http://bit.ly/1tSu4iq">
View Review</td>
</div>
<div class="chart-cont">
<h1>4</h1>
<img src="http://www.spotlightreport.net/wp-content/uploads/2013/06/gran-tourismo-6-banner-3.jpg">
View Review</td>
</div>
<div class="chart-cont">
<h4>View More..</h4>
</div>
</div>
</div>
<!--End of chart-->
This is my CSS code for my two elements:
.chart {
background-color:white;
width:400px;
margin-bottom:10px;
margin-top:-35px;
}
.chart-cont * {
display:inline;
}
.chart-cont {
padding:10px;
box-shadow: 0 2px 5px rgba(26,26,26,0.75);
text-align:center;
}
.chart-cont img {
width:180;
height:60px;
}
.chart-cont h1 {
vertical-align:middle;
}
Any answers greatly appreciated.

First if you want to work with 3/4 of the screen, start using a percentage as width.
First create a content Div, then a LeftContent and a RightContent div.
Like this:
<div class="Content">
<div class="LeftContent">
</div>
<div class="RightContent">
</div>
</div>
CSS:
.Content{
width:100%;
margin:10px;
padding:10px;
}
.LeftContent{
width:60%;
margin:10px;
float:left;
}
.RightContent{
width:30%;
margin:10px;
float:right;
}
Now you can place the video left, and the other images right, adjust how you want to with padding, margin and width percentage, test with making your window smaller (how it looks like on smaller screens).
Notice to make use of float left and float right.
Here is JSFiddle link: http://fiddle.jshell.net/7pp7q/1/

Related

How to adjust/stack floating divs with dynamic height with css only?

I am having hard time to adjust floating div with dynamic heights (with CSS only) if you see the bottom gap i want them to stick together having dynamic height
please check the code here any help would be highly appreciated
.c {
display: inline-block;
width: 100%;
}
.D {
float: left;
}
<div class="c">
<div class="D" style="height:100px; background:blue; width:25%;">
</div>
<div class="D" style="height:200px; background:green; width:25%;">
</div>
<div class="D" style="height:100px; background:pink; width:25%;">
</div>
<div class="D" style="height:120px; background:red;width:25%;">
</div>
<div class="D" style="height:200px; background:red; width:25%;">
</div>
<div class="D" style="height:150px; background:blue; width:25%;">
</div>
<div class="D" style="height:100px; background:green; width:25%;">
</div>
<div class="D" style="height:100px; background:pink;width:25%;">
</div>
</div>
Could this be what you're trying to achieve?
If you end up using this approach, make sure to set the height of .c the sum of the two (or more) tallest, and stacked, .D elements.
https://jsfiddle.net/axelboberg/5pdpf6zh/
Also, try to use as little inline css as possible. It will get messy when your project grows and violates the MVC concept.

Creating <div containers the same height

I'm creating my first web page and I have 3 boxes with an image and text as contet. How do I make the boxes the same height regardless of the content?
New to css etc so please help.
I have tried padding, margin etc but nothing. My code is as follows:
<!------------------------------ Three Small Span Boxes --------------------------->
<div class="container-full-width" id="boxes_lite_section">
<div class="container" >
<div class="container-fluid" >
<!-- Start of markup for boxes lite element -->
<div id="widget_boxes_container" class="row-fluid" >
<div class="boxes">
<div class="box span4">
<p>
***
</p>
<a class="box-link">
<img class="box-image" src=".jpg" />
</a>
<p align="justify" style="margin-top:20px">
content here funding.
</p>
</div>
<!--end box1-->
<div class="box span4">
<p>
***
</p>
<a class="box-link">
<img class="box-image" src=".jpg" />
</a>
<p align="justify" style="margin-top:20px">
content here
</p>
</div>
<!--end box2-->
<div class="box span4">
<p>
***
</p>
<a class="box-link">
<img class="box-image" src=".jpg" />
</a>
<p align="justify">
content here
</p>
</div>
<!--end box3-->
</div>
<!-- end boxes -->
</div><!-- end row-fluid -->
<!-- End of markup for boxes lite element -->
</div>
<!-- .container-fluid-->
</div>
<!-- .container -->
</div>
<!----------------------------- End Three Small Span Boxes ------------------------->
When you set the height for an element, it will be shown with this regardless of the content.
BUT if the content become taller than height, the result may be very ugly.
so, it's better to set overflow:auto in your case, that will save the box height when content is taller...
div.box {
width: 350px; /*for example*/
height:300px; /*for example*/
background: blue; /*for example*/
color:white; /*for example*/
overflow:auto; /*for example*/
border:4px solid red; /*for example*/
}
You can see result Here and you can find out your last question you mentioned in comment...
If you want to hide overflow, try overflow:hidden instead...
If you are dealing with variable height you can use CSS tables to render your divs.
div.boxes { display:table-row; }
div.box { display:table-cell; }
This jsfiddle should give you an indication of what it will look like with your layout.
Practically every major browser supports CSS tables now, so feel free to use them when necessary. Fixed heights are ok, but can cause issues when your content grows beyond your original expected size.

Making Image Divs responsive

I am trying to make the Images in "fullwidthbanner" as fully responsive. May be the problem is that it has two images which I want it to transform with size.
This is my HTML
<div class="main-container col1-layout">
<div class="main row-second clearfix">
<div class="col-main">
<div class="std"><div class="sub-container"><div class="fullwidthbanner-container">
<div class="fullwidthbanner>
<div class="item"><img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="Random Collection"></div>
<div class="item"><img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="Random Collection"></div>
</div>
</div>
</div>
</div>
</div>
CSS
.sub-container {overflow:auto;}
.main-container {background:#fafafa; }
.main { margin:0 auto; position: relative; z-index:1; }
.sub-container div.item{ background-color:red; float:left;}
.sub-container div.item:hover{ background-color:green;}
.sub-container div.item img{ width:100% !important; display:block;}
For some reason, it does everything I want it to, but both the Images are fully extending in terms of width. The width always remain the same and when the window size increases, it just shows an empty space in front of both images.
Assuming this is the html:
<div class="main-container col1-layout">
<div class="main row-second clearfix">
<div class="col-main">
<div class="std">
<div class="sub-container">
<div class="fullwidthbanner-container">
<div class="fullwidthbanner">
<div class="item">
<img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="Eid Collection" />
</div>
<div class="item">
<img src="http://127.0.0.1/www/media/wysiwyg/sub-head1.jpg" alt="Eid Collection" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Does this css do what you want?
.sub-container div.item {
background-color: red;
float: left;
width: 100%;
}
Although I would suggest using max-width, instead of width -- this will make it adapt to smaller screens, and on larger screens it won't get blurry.

how to replace a layout of html web page from a table to using divs

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.

Dividing page into two sections [duplicate]

This question already has answers here:
CSS: Vertical column layout without <table>
(3 answers)
Closed 9 years ago.
I have the below html code. What I need to do is split wuiInPageNav into two sections. LeftArea and wuiMainPageNav and they need to be side by side all the time. LeftAre div will hold my jstree nodes and wauiMainPageNave div will hold my charts and data etc. When I do the following, left goes left and wuiMainPageNav goes to the right. But when I resize the browser window, make it smaller, wuiMainPageNave goes down to the botttom. How do I make sure that LeftArea is always on the left and wuiMainPageName is always on the right, regardles of the browser window and size?missing here. Any ideas?
div id="wuiLeftArea">
<div id="wuiLefthandNavRoot">
<h2 class="wui-hidden">Section Navigation</h2>
<h3 class="wui-navigation-title">Applicaion</h3>
<div id=tree></div>
</div>
</div>
<div id=wuiMainArea>
<div id=wuiMainContent>
<div id=wuiInpageNav>
<div id="top_chart" class="center"> </div>
</div>
</div>
</div>
css:
#wuiInpageNav {left:300px; float:right; width:1200px !important; overflow:hidden; }
div#wuiLeftArea{
float: left;
width: 16.25em;
background-color: #f2f4f5;
padding-top: .5833em;
position: relative;
}
UPDATE
Make sure you don't do your CSS inline:
http://jsfiddle.net/FE79R/1/
HTML
<div id=wuiMainArea>
<div id=wuiMainContent>
<div id=wuiInpageNav>
<div id="left">
<div id="tree">tree</div>
</div>
<div id=main>
<div id="top_charts" class="center"> </div>
<div class="main1">
<div id="top_chart1" class="center">top chart 1</div>
<div id="top_chart2" class="center">top chart 2</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
#wuiInpageNav { width:300px; overflow:hidden; }
#left { width:100px; float:left; position:relative; background-color:#f2f4f5;}
#main { width:200px; float:left; background-color:orange;}