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;}
Related
I have a page with some divs. My page is pretty dynamic where I am showing and hiding divs based on user input.
I want a footer to always appear at the bottom and to have the other divs above it appear in a scroll. Since my data is populated asynchronously, my view loads but then once the content is injected onto the page, my footer seems to move
Here's a simple example of what I'm trying to do:
<div class="parent">
<div class="dynamic-div1">async div1</div>
<div class="dynamic-div2">async div2</div>
<div class="footer">Always appear at bottom</div>
</div>
try to add positions for footer
<div class="parent">
<div class="dynamic-div1">async div1</div>
<div class="dynamic-div2">async div2</div>
<div class="footer">Always appear at bottom</div>
</div>
in CSS
.footer
{
position:absolute;
bottom:0px;
}
in HTML
<div class="parent">
<div class="dynamic-div1">async div1</div>
<div class="dynamic-div2">async div2</div>
<div class="footer">Always appear at bottom</div>
</div>
in CSS
div.parent{
position:relative;
}
div.footer
{
position:absolute;
bottom:0px;
}
Looks like you are looking for the fixed footer at bottom. You can use position:fixed and apply positions like below.
.footer {
position:fixed;
height:20px;
background:#ccc;
bottom:0;
left:0;
right:0;
text-align:center;
}
<div class="parent">
<div class="dynamic-div1">async div1</div>
<div class="dynamic-div2">async div2</div>
<div class="footer">Always appear at bottom</div>
</div>
This question already has answers here:
Why is there vertical scroll on the main container?
(4 answers)
Closed 5 years ago.
I am creating a row of <div> elements using the following code:
HTML:
.row_1_element{
text-align:center;
font-size:3vw;
width:20vw;
float:left;
}
<div id="row_1">
<div class="row_1_element">
Menu
</div>
<div class="row_1_element">
user
</div>
<div class="row_1_element">
profile
</div>
<div class="row_1_element">
?
</div>
<div class="row_1_element">
?
</div>
<div>
The problem is that all 5 <div> elements do not fit into one row across the screen, instead 4 fit and the 5th goes to the next row. This makes little sense if 1vw is 1/100 of the viewport width, since 5 *(20/100) = 100/100 viewport width. Therefore there should be enough space for all 5 of them to fit.
You must remove the default margins from the page if your content spans the entire 100%:
body {
margin: 0;
}
.row_1_element {
text-align:center;
font-size:3vw;
width:20vw;
float:left;
}
<div id="row_1">
<div class="row_1_element">
Menu
</div>
<div class="row_1_element">
user
</div>
<div class="row_1_element">
profile
</div>
<div class="row_1_element">
?
</div>
<div class="row_1_element">
?
</div>
<div>
Okay I do not know wether I have started completely wrong or just do not know how to get it right.
I want the layout of my website to be like this:
I put a div called 'myWrap' around the header and the content. And added this css:
.myWrap {
position: absolute;
padding: 0px;
margin: 0px;
background: white;
top: 2%;
left: 2%;
right: 2%;
}
.footer {
position: absolute;
background: #363130;
margin-top: 2%;
height: 300px;
left: 0;
width: 100vw;
}
And the footer is not in the myWrap-div. But now it is just floating behind the content because the position of the myWrap is absolute.
How do I put the header and content in the normal flow but infront of the background?
I structured the html like that:
<div class="row container-fluid myWrap">
CONTENT
<div class="container-fluid footer">
FOOTER
</div>
</div>
If I put the footer out of the myWrap div it starts floating around on the top or just overlaps the content/header
Change .myWrap to position: relative, your footer is getting the position absolute of the body, because It dosn't have a parent element with a relative position CSS atribute.
.myWrap {
position: relative;
}
With this, you will get your footer always on the bottom of myWrap. Then you can play with, the top/bottom properties and place it where you want ;)
I have created a Bootply to show it how it's working: http://www.bootply.com/8Wmx3CJHFv
Try this
<div class="myWrap">
<div class="container">
<div class="row">
Then add your footer after the end of the container
Personally, I would not work with your own wrapper. Bootstrap made them with a reason and that reason is they will work perfectly for responsive viewports.
I'd suggest you enhance something like this:
HTML
<html>
<body>
<header>
<div class="container">
<div class="row">
<div class="col-lg-12">
// content here
</div>
</div>
</div>
</header>
<section id="content">
<div class="container">
<div class="row">
<div class="col-lg-12">
// content here
</div>
</div>
</div>
</section>
<footer>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
// content here
</div>
</div>
</div>
</footer>
</body>
</html>
CSS
body {background-color: #FFF;}
footer {background-color: #FFF;}
header {background-color: #FFF;}
.container-fluid {padding: 0 0;}
Just make sure you remove the padding for the .container-fluid. And a tip: if you ever feel like creating your own wrapper, don't position them with absolute, but with relative. Otherwise it won't work well on all viewports.
You mentioned that you are using bootstrap, in bootstrap the container class wraps your data into a wrapper that has a fixed width on each screen-device-width so you will need to add a container div for the header and the content without adding it inside the footer div.
If you are using bootstrap framework you will need to use these following classes for these div's as the following code:
<div class="site-container">
<div class="header">
<div class="container">
</div>
</div>
<div class="content">
<div class="container">
</div>
</div>
<div class="footer">
</div>
</div>
<style>
body{
background:url(../image.jpg);
}
header {
max-width:600px;
width:100%;
display:block;
background:#ccc;
height:250px; //header height no need to mention in your work
border:1px solid #000;
margin:auto;
}
#content {
max-width:600px;
width:100%;
display:block;
background:#ddd;
height:500px; //content height no need to mention in your work
border:1px solid #000;
margin:auto;
}
footer {
width:100%;
height: 300px;
left: 0;
background:#000;
}
</style>
<header>
<div class="container">
<div class="row">
<div class="col-lg-12">
// Header
</div>
</div>
</div>
</header>
<section id="content">
<div class="container">
<div class="row">
<div class="col-lg-12">
// Content
</div>
</div>
</div>
</section>
<footer>
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
// content here
</div>
</div>
</div>
</footer>
Demo: https://jsfiddle.net/q4Lcjmsy/3/
This is difficult to explain so please see this fiddle: http://jsfiddle.net/vhfhzgfz/
Say I have a row of 4 columns using Bootstrap. I want the content within these cols to be equal distances apart. The content has a fixed width in px.
The content in the first column needs to be aligned to the left (edge of the page) and the content in the last col aligned to the right (the other edge of the page). This is fine.
But how do I align the content in the middle two columns to ensure the space between the content is equal.
Here's the code form the fiddle:
<div class="container">
<div class="row">
<div class="col-xs-3 left">
<div class="wrapper"></div>
</div>
<div class="col-xs-3 center">
<div class="wrapper"></div>
</div>
<div class="col-xs-3 center">
<div class="wrapper"></div>
</div>
<div class="col-xs-3 right">
<div class="wrapper"></div>
</div>
</div>
</div>
.col-xs-3{
background:lightblue;
outline:solid 1px black;
}
.wrapper{
width:100px;
height:100px;
background:pink;
position:relative;
display:inline-block;
}
.left{
text-align:left;
}
.right{
text-align:right;
}
.center{
text-align:center;
}
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/