Bootstrap container with content and facebook buttons on the side - html

I use bootstrap and have all my content in a container; this centers all the content just the way i want it. The problem is that i also want a fixed bar on the right side with width 250px with facebook like button and maybe some text.
What i also want is that when i re-size the browser to mobile view the whole right bar will appear on the bottom right after the container.
I have tried to make rows around the containers but that did not work work
<div class = "row" >
<div class = "col-sm-6 col-md-4">
<div class ="container">
...
</div>
</div>
<div class = "col-sm-6 col-md-4">
<div class ="container">
...
</div>
</div>
</div>
I also tried to float a div to the right, but that wont work in the mobile view..
I have googled this for hours, downloaded webpages to see source code, and tried a lot of things i cant even remember with no result. Does anyone have an idea?

Here is an fiddle if it can help you :
bootply http://www.bootply.com/117047
html
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8 leftarea">
left area
</div>
<div class="col-xs-12 col-sm-4 right-atea">
<div class="row tofix">
<div class="well col-xs-12 rightfixed">
right fixed
</div>
</div>
</div>
</div>
</div>
css
.leftarea{
height:950px;
background-color:blue;
color:white;
}
.rightfixed{
background-color:red;
height:250px;
}
#media (min-width: 940px) {
.rightfixed{
position: fixed;
width:250px;
}
}

I can see that my question might be a bit unclear. And i see that my code attempts are rubbish. But i found a solution:
<div class = "container">
<div class = "row">
<div class = "col-lg-9">
<div class = "panel panel-default">
<div class = "panel-body">
Main content
</div>
</div>
</div>
<div class = "col-lg-3">
<div class = "list-group">
Side Bar Content
</div>
</div>
</div>
</div>
This will make a main content container with a bar on the side for different elements.
Coder's Guide on YouTube have a great tutorial for this. ( http://goo.gl/ZfH6rk )

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
}

CSS and html: adding margins result in elements not being in a row

I have some html code that has some elements in rows:
<div class = "row">
<div class="col-sm-3 cont-box">
<h1>Title1<h1>
</div>
<div class="col-sm9 cont-box">
<img src="onepic.jpeg" class="img-responsive" alt="dum1">
</div>
</div>
When I add margins to the class cont-boxmy browser displays the two elements underneath each other, a line break is added. I would like them to be next to each other, what am I missing?
I am completely new to CSS and html, so any help is much appreciated.
When you add a margin to bootstrap grid that time when its width reaches above the 12 column grid that time it automatically pushes to down.
To do this add div inside the col-sm-3 and col-sm-9 and add margin to it.
<div class = "row">
<div class="col-sm-3">
<div class="cont-box">
<h1>Title1<h1>
</div>
</div>
<div class="col-sm-9">
<div class="cont-box">
<img src="onepic.jpeg" class="img-responsive" alt="dum1">
</div>
</div>
</div>

How to create left and right side inside container?

What i have is sidebar and on right side i have content. What i want is that both sides are in container but that are both full width . This is my demo: https://jsfiddle.net/DTcHh/19067/
So i want that left background color start from beging of page but text inside is in container and also i want that background color of right content go to the end of page but text is in container. Any suggestion?
<div class="container">
<div class="col-md-3">
<div class="left_sidebar">
menu
</div>
</div>
<div class="col-md-9">
<div class="right-content">
content
</div>
</div>
</div>
Its simple, wrap the colored containers above the container class and use two different containers:
<div class="left_sidebar">
<div class="container">
<div class="col-md-3">
menu
</div>
</div>
</div>
<div class="right-content">
<div class="container">
<div class="col-md-9">
content
</div>
</div>
</div>
Here is a working Fiddle
REMOVED other edits because EDIT 3 should do the trick best
EDIT 3
Here it is, that must be it for sure now. The trick is done with a linear gradientand a custom container above your bootstrap container.
See Fiddle
What you're asking, is by default impossible, since the .container class has a set width on different viewports and it is also horizontally "centerised" by margin:auto.
To achieve what you are trying you will have to follow a different "logic".
I would propose something like this:
<div class="left-sidebar col-md-3">
<div class="sidebar-menu col-xs-6 pull-right">
menu
</div>
</div>
<div class="right-content col-md-9>
<div class="content-text col-xs-10>
content
</div>
</div>
I propse this solution in order to stay in the same "flow" as your code. You could also, just play with paddings, which makes more sense.
use class row before col div
<div class="row">
<div class="col-md6"></div>
<div class="col-md-6"><div>
</div>

overlapping rows and sections html css bootstrap

I am having an issue with overlapping elements which I don't want. I'm sure it's all right but I can't work out why. This is a one page lay out with a fixed navigation on top. There are five sections home, services, gallery, contact, about. The service section is behind the about section when zooming. I wrote this example to illustrate my point. CSS, HTML, Bootstrap 3
//css
section {
position:relative;
padding:80px 0;
min-height:100%;
}
<section id ="services">
<div class = "container">
<div class = "row">
<div class="col-md-4">
some text and an icon etc...
</div>
<div class="col-md-4">
some text and an icon etc...
</div>
<div class="col-md-4">
some text and an icon etc...
</div>
</div>
</div>
</section>
<section id = "about">
<div class = "container">
<div class = "row">
When zoom in they stack but only show the first block in the service section the other two blocks are hidden behind the about section.
use :
*{
box-sizing: border-box;
}
it will solve .

How to properly display content when I resize the window?

I have my page structured into 3 different modules: navigation on the left, images in the center, and social sidebar right. Below is the css that formats this content. I'm having trouble when I resize the window; the images in the center overlap with the navigation on the left and the sidebar gets pushed to the bottom of the page and overlaps with the end of the left navigation. The navigation module/sidebar is fixed.
I'm using twitter bootstrap as a base.
Any ideas on what's causing this and how to fix this?
css
div.sidebar{
width: 120px;
position:fixed;
top:12%;
left:2%;
overflow-y:auto;
height:100%;
}
html
<div class ="container-fluid">
<div class = "row-fluid">
<!-- left navigation div -->
<div class = "span1" style = "width:120px;">
<div class = "sidebar" >
#navigation
</div>
</div>
<!-- middle images div -->
<div class = "span8" style = "width: 900px;">
#lot of images
</div>
<!-- social sidebar -->
<div class = "span2" style = "margin-left: 10px; ">
#social module with images
</div>
</div>
</div>
when I make the window smaller
normal
Have you thought about responsive web design?
You say your using twitter bootstrap? Have a look at this:
http://twitter.github.com/bootstrap/scaffolding.html#responsive
Add this to the head
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
Change the HTML:
<div class="container-fluid">
<div class="row-fluid">
<!-- left navigation div -->
<div class="span4">
<div class = "sidebar" >
#navigation
</div>
</div>
<!-- middle images div -->
<div class="span6">
#lot of images
</div>
<!-- social sidebar -->
<div class="span4">
#social module with images
</div>
</div>
NOT TESTED. Im also not 100% how big the fluid container is, i think its 12, if its 16 you will have to change the spans so they add up to 16
Couple issues I see...
You are completely defeating the purpose of ".row-fluid" and the framework by adding widths?? Remove all width assignments to the grid elements (ie. .container, .row, .span(x)) and let the framework do what it was designed to do...create the width for you. If you need to adjust width from what is being generated, add it to block level element INSIDE of the .span(x).
Your span HAVE to add up to NO MORE than 12. You have 14 which will absolutely make the last wrap around.
Overriding the spans with inline widths will cause odd behavior. Can you use the default TBS scaffolding instead?
Suggestions :
1.Remove all the extra things you put for style let bootstrap do the things !!
2.always test your div with "well"
Put your codes like this
<div class="container">
<div class="row" style="margin-top:20px;">
<div class="col-lg-3 col-sm-12 ">
<div class="well"></div>
</div>
<div class="col-lg-3 col-sm-12 ">
<div class="well"></div>
</div>
<div class="col-lg-3 col-sm-12 ">
<div class="well"></div>
</div>
<div class="col-lg-3 col-sm-12 ">
<div class="well"></div>
</div>
</div>
col-lg-* for large device
col-xs-* for extra small device
col-sm-* for small device
use it like this you can achieve what you want
Plunker demo
resize your browser to view the effect