jumbotron height and float - html

im kind of new to css/html and bootstrap itself. I've encountered two problems.
One is: I want to fix the 3rd and 4th box height to 100%, but no mater what div, or class i change to 100% it makes no changes.
Second: How can i make Box4 go under box2, so its not inline with box3?
Link to describe problem: http://jsfiddle.net/BXZrX/6/
and here is a picture of what i want: http://oi62.tinypic.com/osqule.jpg
<div id="content">
<div class="jumbotron">
<div class="container-fluid">
<h1>Join now!</h1>
<p>To get full use of the website, register now!.</p>
Sign up
</div>
</div>
<div class="bordertop">
<div class="jumbotron">
<div class="container-fluid">
<h1>Box2</h1>
<p>text</p>
</div>
</div>
</div>
<div class="box3">
<div class="jumbotron">
<div class="container-fluid">
<h1>Box3</h1>
<p>text</p>
</div>
</div>
</div>
<div class="box4">
<div class="jumbotron">
<div class="container-fluid">
<h1>Box4</h1>
<p>text</p>
</div>
</div>
</div>
</div>
#content > div {
float:left;
width:49%;
}
#content > div.bordertop {
float:right;
width:49%;
}
#content > div.box3 {
clear:both;
width:49%;
float:left;
}
#content > div.box4 {
float:right;
width:49%;
}

Here's a start:
http://jsfiddle.net/jPZLd/11/
I've swapped boxes 2 and 3 so that they flow correctly down then across the page:
<div id="content">
<div class="column">
<div class="jumbotron">
<div class="container-fluid">
<h1>Join now!</h1>
<p>To get full use of the website, register now!.</p>
Sign up
</div>
</div>
<div class="bordertop">
<div class="jumbotron">
<div class="container-fluid">
<h1>Box2</h1>
<p>text</p>
</div>
</div>
</div>
</div>
<div class="column">
<div class="box3">
<div class="jumbotron">
<div class="container-fluid">
<h1>Box3</h1>
<p>text</p>
</div>
</div>
</div>
<div class="box4">
<div class="jumbotron">
<div class="container-fluid">
<h1>Box4</h1>
<p>text</p>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
Footer
</div>
If you need both boxes 2 and 4 to have the same baseline, it's easy if your content is static - just adjust the height of the shorter box manually, eg.
.box4 .jumbotron {
height: 319px;
}
It gets a bit harder if you have to deal with dynamic content. I think you'd end up needing to fake it by applying the background color to the container element and hiding the bits you don't want to see.

Related

Ignoring CSS margins for embedded DIVs

I have a classic bootstrap template, like this:
<div class="container">
<div class="row">
<div class="col-12">
...header...
<div class="carouselContainer">
...carousel...
</div>
...content...
</div>
</div>
</div>
and now my website looks like this (H - header, S - slider, C - content, F - footer, with margin: auto):
I want to (visually, using CSS) pull out slider from div.row and div.col-12, like this.
I have tried using position:absolute, but after that, part of content is hidden under slider, plus I want to keep everything safe on different screen resolutions (not using pixels, and maybe on smallest screens carousel will be hidden).
does anyone have an idea how to do it? (I'm sorry if I complicated.)
Try simply stacking different .containers, like this...
<div class="container">
<div class="row">
<div class="col-12">
...header...
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="carouselContainer">
...carousel...
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-12">
...content...
</div>
</div>
</div>
You shouldn't nest .container's but you can stack them! In this case container-fluid will go full width. the others won't.
Why not change the HTML structure and use a container-fluid to wrap your slider.
It would be better ( imho ) to use HTML tags for elements like <header> <main> <footer>
So a structure would be
<header>
<div class="container">
<nav>
Nav here
</nav>
</div>
</header>
<main>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="slider">
Slider Here
</div>
</div>
</div>
</div>
<div class="container content">
<div class="row">
<div class="col-12">
Content Here
</div>
</div>
</div>
</main>
<footer>
Footer Here
</footer>

background-colors not showing up

I can't get the colors to show up in chrome. I've tried switching the order of the files in <link> just in case that is the problem. I don't see any reason why the colors are'nt showing up in chrome.
.header {
background-color: white;
}
.body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container"></div>
</div>
Your .body class DIV doesn't have any content. If you put some text into it, you see the blue background:
(and since the browser windows background is white by default, you won't see the white background on your .header DIV...)
.header {
background-color: white;
}
.body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container">Here is some content</div>
</div>
.header {
background-color: white;
}
body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container"></div>
</div>
I assume you are trying to change the entire page background color which needs to be done with a body { ... } selector not .body{ ... } as in this sample.
However, if the goal is to target the with a class of body your CSS is correct but there is nothing inside for content so it has a height of 0 by default. Add content like Johannes mentioned and it should work for you.

How to stack Bootstrap row inside of another row?

I have a Bootstrap page on which I'm trying to stack different boxes.
Imgur - Image of boxes (sorry, not enough rep to upload images directly)
The green boxes are the ones currently in position, and the red ones are the ones I am having issues with. I'm using the following code (simplified) to get the green boxes:-
<div class="container">
<div class="row">
<div class="col-xs-3" style="height:100px; background-color:green;">
</div>
<div class="col-xs-3" style="height:100px; background-color:green;">
</div>
<div class="col-xs-6" style="height:200px; background-color:green;">
</div>
</div>
</div>
I'm basically trying to create another two <div class="col-xs-3" style="height:100px; background-color:green;"> that will go underneath the current two, while also keeping the large box to the right.
I thought it would be an easy fix with a new row, or using float:left / right, but none of that seems to be working out.
One way to do it would be to make two 50% width columns and then divide the column on the right into two rows with two more columns in each:
.green-lrg {
background-color:green;
height:215px;
}
.green-sml {
background-color:green;
height:100px;
}
.red-sml {
background-color:red;
height:100px;
}
.col-xs-6 .row {
padding-top:15px;
}
.col-xs-6 .row:first-child {
padding-top:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<!-- LEFT COLUMN -->
<div class="col-xs-6">
<div class="green-lrg"></div>
</div>
<!-- RIGHT COLUMN -->
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6">
<div class="green-sml"></div>
</div>
<div class="col-xs-6">
<div class="green-sml"></div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="red-sml"></div>
</div>
<div class="col-xs-6">
<div class="red-sml"></div>
</div>
</div>
</div>
</div>
</div>
Here is simple example.
HTML
<div class="container">
<div class="row">
<div class="col-xs-6 box box-big">
</div>
<div class="col-xs-6">
<div class="row">
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
<div class="col-xs-6 box box-small">
</div>
</div>
</div>
</div>
</div>
and CSS:
.box {
background-color:green;
border:5px solid white;
}
.box-big {
height:200px;
}
.box-small {
height:100px;
}

How come one of my columns in bootstrap is not functioning properly?

I am making a site for my high school robotics team and I am completely new to html and css. How come one of the columns (the member 10 one) is not functioning like the others?
It seems one of the columns is off center. I'm not sure exactly how to describe it but I can post an image if necessary.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Robotics Team</title>
<!-- Link to stylesheet -->
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/index1.css">
<!-- Mobile Scaling -->
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-------------------- UNIFORM CODE ------------------------->
<!-- Navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/Home">Team 3774</a>
</div>
<div class="navbar-collapse collapse" style="height: 0.866667px;">
<ul class="nav navbar-nav">
<li>Team Bio</li>
<li>Our Robot</li>
<li>Our Coach</li>
<li>Gallery</li>
<li>Outreach</li>
<li>Youtube</li>
</ul>
</div>
</div>
</div>
<!-- Banner -->
<div id="top-jumbotron" class="jumbotron">
<img src="/Images/Banner.png" class="img-responsive" alt="Responsive image">
</div>
<!----------------------------------------------------------->
<div class="jumbotron">
<h1>Team Member Bio</h1>
<p>Here you can find links to every member with some information on each of them.</p>
</div>
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="bubble">
<h2>Member 1 </h2>
<p>Team Captain, Engineer, Coder</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 2</h2>
<p>Head Engineer, Assistant Captain</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 3</h2>
<p>Head Coder, Head Web-master</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 4</h2>
<p>Coder, Head Documenter</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 5</h2>
<p>Engineer, Head 3D Modelling</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 6</h2>
<p>Coder, Web-master, Engineer</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 7</h2>
<p>Financial Advisor, Engineer</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 8</h2>
<p>Engineer, Documenter</p>
Read More
</div>
</div>
<div class="col-md-4">
<div class="bubble">
<h2>Member 9</h2>
<p>Engineer, Coder</p>
Read More
</div>
<div class="col-md-4">
<div class="bubble" id="special">
<h2>Member 10</h2>
<p>Secretary, Mascot</p>
Read More
</div>
</div>
</div>
</div>
</body>
</html>
#top-jumbotron
{
padding-left:0;
padding-right:0;
padding-bottom:0;
margin-bottom: 0;
}
body
{
background-color: #E8E8E8;
}
.bubble
{
background-color: #ffffff;
padding: 20px;
width: 95%;
height: 175px;
border-radius: 15px;
margin-top: 10px;
margin-bottom: 10px;
}
#special
{
float: left;
}
You're just missing a /div - I notice you have a div inside a div, remember you need to close both. I use Netbeans for html and it will tell you if there is a problem. If you are on a Mac, I am told Komodo is really good, too. A good editing program is a life saver!
Fixed code:
<div class="col-md-4">
<div class="bubble">
<h2>Mina Hanna</h2>
<p>Engineer, Coder</p>
Read More
</div>
</div> <!-- this one! -->
edit there are a few things wrong with the code and michael points one out - as he says, Bootstrap is a grid. So Imagine (I actually draw it usually) a box split into 12 columns. For every row div, you should only have columns that add up to 12 inside it. You can break this and it will often still work because the div will just overflow and move down, but it's not best practice. If fixing the missing div end tag doesn't work, try fixing the row structure so it only adds up to 12 columns across the page
You can have a layout like the one you specify, however it wont necessarily work per Bootstraps intended functionality, and as such its usually a good idea to follow their recommended row structure.
Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases.
Instead of
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
...
</div>
You should do, e.g:
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-2"></div>
<div class="col-md-2"></div>
<div class="col-md-2"></div>
<div class="col-md-2"></div>
<div class="col-md-2"></div>
</div>
Within a row, the sum of the numbers following the hyphen in each column definition should add up to 12.

parent negative margin with nested floated divs wont follow the parent if object overlaps

Heh, sorry for the long title, but I need a fix for this and have been on it for some time now.
Basically there is a header and I'd like to move content underneath it.
Everything is relative (keeping it centered)
so header has a margin top, z-index, ecc.
The page is relative with a negative margin and contains nested floated columns that wont go up past the header (dammit) and cannot figure out why.
I would like to avoid using absolute positioning if possible.
Here's the code:
<div class="header wrapper-standard">
<div class="logo">
<div class="inside">hello</div>
</div>
<div class="menu-wrapper-outer">asda</div>
<div class="clear"></div>
</div>
<div class="about-page wrapper-standard notop">
<div class="about-page content">
<div class="about-block wrapper-long">
<div class="col col-left text-first">
asda
</div>
<div class="col col-right">
lol
</div>
<div class="clear"></div>
</div>
<div class="about-block wrapper-long">
<div class="col col-left text-first">
asda
</div>
<div class="col col-right">
lol
</div>
<div class="clear"></div>
</div>
<div class="about-block wrapper-long">
<div class="col col-left text-first">
asda
</div>
<div class="col col-right">
lol
</div>
<div class="clear"></div>
</div>
</div>
</div>
Here's the fiddle:
fiddle
Thanks.
Here is a very basic example of how you can have a fixed width, centered page with a fixed header which allows the content to flow underneath:
CSS:
<style type="text/css">
.wrapper{
height:600px;
margin:0 auto;
width:400px;
background-color:#0ff;
}
.header_wrapper {
position:fixed;
background-color:#ffd800;
}
.header {
width:400px;
background-color:#f00;
height:100px;
}
.page {
padding-top:100px; /*height of header*/
}
</style>
HTML:
<body>
<div class="wrapper">
<div class="header_wrapper">
<div class="header">Header</div>
</div>
<div class="page">
Content will be here bla bla etc
</div>
</div>
</body>
Here is a fiddle so that you can see it working: http://jsfiddle.net/JjBG5/1/