Make a div stretch across the page overflowing its containing div - html

I am having difficulty making a div stretch across the page overflowing its containing div.
I am using WordPress child theme of twenty thirteen theme importing bootstrap CSS file only, no JavaScript files (yet anyway!).
I am using this div called section to add styling just to add a background image or colour like this websites orange section please see link below:
Flat Web Design
I have tried
position: absolute;
left: 0;
right: 0;
but position: absolute seems to play havoc with the grid.The section div appears in the correct place, however the following divs sit on top of the "section" div.
I am aware of HTML5 section tag. But as I understand it, it is not best practice to use section for styling only, but to use a div instead? However I have experimented with the section tag and I have the same problem.
I hope someone can advise how I can make a div stretch across the page overflowing its containing div? Can this be done without position absolute?
Thanks in advance
My MarkUp
<div id="content" class="site-content" role="main">
<div class="entry-content">
<div class="container">
<div class="section">
<div class="row">
<div class="col-md-4">
<?php the_field('title'); ?>
</div>
<div class="col-md-4">
<?php the_field('content'); ?>
</div>
<div class="col-md-4">
<?php the_field('image-item'); ?>
</div>
</div>
</div>
</div>
</div>
</div>
My CSS
.entry-header,
.entry-content,
.entry-summary,
.entry-meta{
margin: 0 auto;
max-width: 1150px;
width: 95%;
}
.section{
background:#e8e5ce;
position:absolute;
left:0;
right:0;
}

To achieve this kind of layout you can't use a single container, each section should have its own .container element, this way the section covers the width of the window but the content is centered:
HTML
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-4">
<?php the_field( 'title'); ?>
</div>
<div class="col-md-4">
<?php the_field( 'content'); ?>
</div>
<div class="col-md-4">
<?php the_field( 'image-item'); ?>
</div>
</div>
</div>
</div>
CSS
.section{
background-color:#e8e5ce;
}

Related

Bootstrap data-affix/position-fixed col overlapping other col

I'm having an issue with my bootstrap website. I have my site setup like so:
<div class="container">
<div class="row">
<div class="col-md-9" style="text-align:left;padding-top: 2%">
Some content
</div>
<div class="col-md-3" style="position:fixed">
Scrolling Sidebar
</div>
</div>
</div>
I have been trying to wrap my head around why the side bar is floated all the way to the left and is a col-3 but with a larger container so it's much larger on my screen. Has anyone seen something like this before?
The reason why there is overlapping conent is that when you make something position:fixed - it takes it out of the page flow and the remaining contents take its place. You need to explicitly set the width when it is fixed. In the following i am using a class "is-fixed" to set the fixe position styling.
<div class="container">
<div class="row">
<div class="col-md-9" style="text-align:left;padding-top: 2%">
Some content
</div>
<div class="col-md-3 is-fixed">
Scrolling Sidebar
</div>
</div>
</div>
//css style for element that is fixed
.is-fixed {
position:fixed;
top:0;
right:0;
width:200px; // or whatever
}

Make element appear to the right of a div

I'm making this little website, and I'm trying to make user profiles. I'm honestly not the best with HTML and CSS but basically, my problem is, that I want to display the profile picture in the top left of the "jumbotron" (I'm using bootstrap), and have the username just to the right of it, with a little paragraph/quote/motto beneath the username. However, I cannot get it to work.
Here is my current code:
HTML
<div class="container">
<!-- Profile Jumbotron-->
<div class="jumbotron">
<div class="profile-picture">
</div>
<h1><?php echo "$profile_name" ?></h1>
</div>
</div>
CSS:
.jumbotron {
margin-top: 5%;
margin-bottom: 2%;
}
.profile-picture {
width: 200px;
height: 200px;
background-color: white; /* Just as a test profile picture */
}
Here is the result of this code
I have tried to right-align the text, but to no avail.
Of course, there's the obvious float:right, which works well enough, but then the height of the jumbotron gets all screwed up! Unless I am doing something wrong with that.
So with all that said, I hope someone can help me, as you seem pretty helpful here!
Thank you for taking the time to read my issue, and I hope you can assist me in fixing it!
<div class="container">
<!-- Profile Jumbotron-->
<div class="jumbotron col-md-12">
<div class="profile-picture pull-left col-md-5">
<img class="img img-responsive" src="Your image" style="width:200px"/>
</div>
<h1 class="pull-right col-md-7">
<?php echo "$profile_name" ?>
</h1>
</div>
</div>
.profile-picture {
background-color: white; /* Just as a test profile picture */
}
I think something like this would do the trick since you are using bootstrap framework. Note the css classes I have put pull-left and pull-right. col-md-5 and col-md-7 are used to divide the div columnwise.
by using img-responsive you will be able to proportionally align image inside the div.
You can do one easy thing (picture, name and quote are all divs):
<------------------- LARGE DIV ------------------->
<---PICTURE(float:left) NAME(float:right)
<br>
QUOTE(float: right)
<------------------------------------------------->
How to accomplish this:
<div id="profileContainer" style="width: 800px;">
<div id="picture" style="width: 200px; float: left;"><img src="yourimage.jpg"></div>
<div id="name" style="width: 400px;"><?php echo "$profile_name" ?></div>
<br>
<div id="quote" style="width: 400px; float:right;">Text about stuff</div>
</div>
So basically you have the profileContainer div with a width you want, the picture with the width of the div being the picture size and the name floating to the right. By changing the profileContainer width you can get the name closer to the picture, or you can also set a margin-right: #px; on the Name and the Quote.

Restrict height of CSS table - ignore content height

I am having trouble with a CSS table I am using for layout. Not a traditional table but a set of div's using display:table etc.
The problem is that it works great when one of the cell div's is empty, however as soon as I add content to it, the table stretches to accommodate the content.
#dispcontainer {
display: table;
width:100%;
height:100%;
overflow-y: scroll;
max-height:100%;
table-layout:fixed;
border-collapse:collapse;
}
.disprow {
display: table-row;
width:100%;
}
.dispcell {
display: table-cell;
width:100%;
height:100%;
}
The HTMl:
<body>
<div class="box">
<div class="content">
<div id="dispcontainer">
<div class="disprow">
<div class="dispcell">
<img class="heading_img" src="img/heading.png" /><br />
<div class="nav_buttons">
<?php include("menu.html"); ?>
</div>
</div>
</div>
<div class="disprow">
<div class="dispcell">
<div style="height:100%;overflow:hidden;">
<?php include("tumblr/tumblrFeed.php"); ?>
</div>
</div>
</div>
</div>
</div>
<?php include("social_buttons.html"); ?>
</div>
<div id="contactBar"><?php include("contactDetails.html")?></div>
</body>
And the website proper is here: http://fadeinfuture.net/users/tbw/test2.php
I just don't understand how to get the table to never become taller than it's containing div.
I got it working with regular <table>'s, however Internet Explorer didn't like it basically with the same problem.
The reason for this layout is that I want the heading to be fluid depending on the screen width and the area below to take up the rest of the screen.
Try moving your overflow-y: scroll; to the box div.
You can use JavaScript and jQuery. (with pure css it MAY BE more difficult)
<script>
$(function() {
$("#parent").height($("#child").height());
});
</script>
I use something like that on my website.

bootstrap basic grid

In an attempt to learn responsive web design, I am teaching myself how to design with bootstrap. I have created a basic grid; the code for the grid is shown below.
HTML:
<div class="row">
<div class="span6 red01">span6</div>
<div class="span6 green01">span6</div>
</div>
CSS:
body { padding: 0px; }
.red01 { background: #ff0000; }
.green01 { background: #00ff00; }
I can see the two divs on my web page, but my problem is with how they are aligned. I'd like to align them horizontally across my laptop's screen. I've tried fiddling with this, but can't get it to work. Could anyone please lend their expertise?
Please check this JSfiddle for you
See the result here Result of 2 col
<div class="container">
<div class="row">
<div class="span12">
<h1>Bootstrap 12 col spanning full page</h1>
</div>
<div class="span6">
<p> Paragraph test col1</p>
</div>
<div class="span6">
<p> Paragraph test col2.</p>
</div>
</div>
</div>
.container class -> Its a wrapper with fixed width , predefined in bootstrap.css .
.container-fluid -> which is fluid wrapper
.row --> This class is built to contain a row of columns. Each new row creates a new zone for laying out columns as desired.

Best way to markup an HTML banner

The general html structure of my pages is
<div id="wrapper">
<div id="header">
</div>
<div id="content">
</div>
<div id="footer">
</div>
</div>
I have a 1000px layout with the content centering.
However, for a couple of the pages I have a banner in the content that should expand 100% to the sides of the browser (i.e., beyond the 1000px wrapper).
Should I delete the wrapper div for this page and apply width: 1000px; margin: 0 auto; separately? Or should I take the banner outside of the standard wrapper layout? What is a more standard way to do this?
Thank you.
Using style="overflow:show" for that content banners parent should allow it to show. Instead of width=100% you might need to use some javascript to get the screens width and make it that width.
I would take the banner outside of the wrapper.
I had same problem and done something like this:
.center
{
margin: auto;
width: 1000px;
}
<div id="wrapper">
<div id="header">
</div>
<div id="content">
<div class="center">
</div>
<div id="banner">
</div>
<div class="center">
</div>
</div>
<div id="footer">
</div>
</div>