First of all, I am really new to Bootstrap so please excuse my newbiness.
The problem is that I am trying to create some sort of a thread list and when I shrink the width of the page all the contents keep moving down one another.
This is what I want:
http://img04.imgland.net/CmWzwDR.png
Things just becoming smaller and nothing going out of place
This is what happens:
http://img04.imgland.net/hNKc_Ok.png
Ya its pretty bad
Do you guys know of any way to fix this problem? I don't have to use bootstrap, but I thought it would be easiest.
Thanks
<div style={{marginTop: "80px", marginLeft: "20px", marginRight: "20px"}}>
<div style = {{height: "80px", marginBottom: "10px", padding: "1px 1px 1px 1px", border: "2px solid #000000"}} class="row-fluid" >
<div class = "col-xs-2" style= {{width: "20px", float: "left"}}>
<div class = "row" >
<img src="img/upvote.png" />
<img src="img/downvote.png" />
</div>
</div>
<div class = "col-xs-2" style={{width: "100px", marginLeft: "0px", padding: "0px 0px 0px 0px", float: "left"}}>
<img src={thumbnail} style={{height: "80px", width: "100px"}}/>
</div>
<div class = "col-xs-8" style= {{marginLeft: "10px"}}>
<div class = "row">
<h3 style = {{height: "50px", textAlign: "left", marginTop: "0px", marginBottom: "0px", padding: "0px 0px 0px 0px"}}> {title} </h3>
<p style = {{height: "30px", textAlign: "left", marginBottom: "0px", padding: "0px 0px 0px 0px", overflow: "hidden"}}> {desc} </p>
</div>
</div>
</div>
</div>
Currently this is my site on desktop screen:
img.imgland.net/5VBEme.png
And then this is what it would look like on mobile: img02.imgland.net/cr-MUQd.png
Without explicit samples of your code, I assume it has something to do with the grid prefix you are using. Take a look at http://getbootstrap.com/css/#grid-options which shows the 4x different prefixes:
.col-xs-*
.col-sm-*
.col-md-*
.col-lg-*
To control the behaviour of your layout on mobile resolutions use the .col-xs-* class. Bootstrap documentation gives a great example: http://getbootstrap.com/css/#grid-example-mixed
The above exmaple shows how to mix classes to have different behaviour on different resolutions:
<div class="row">
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
Using this code will have your columns start at 50% wide on mobile and bump up to 33.3% wide on desktop. Using these combinations allows you to have quite a fine control over layout across all container resolutions.
EDIT BASED ON CODE SUPPLIED:
<div class="container-fluid">
<div class="row">
<div class="col-xs-2">
<img src="img/upvote.png" />
<img src="img/downvote.png" />
</div>
<div class="col-xs-2">
<img src="#" />
</div>
<div class="col-xs-8">
<h3>{title}</h3>
<p>{desc}</p>
</div>
</div>
</div>
Pay close attention to the Bootstrap docs which show how to use containers and the grid system. I would also take note of the Column nesting as this is a great way to show columns contained within columns: http://getbootstrap.com/css/#grid-nesting
EDIT BASED ON SECONDARY QUESTION
Use the element inspector function in your browser to have a detailed look at your CSS classes and what is creating the padding between columns. You can then call your own custom.css file (or re-compile if you are competent with Less) which overrides the default Bootstrap styling. This will remove the left and right padding in the example code I have supplied:
.col-xs-2, .col-xs-8 {
padding-right: 0px;
padding-left: 0px;
}
Related
Here's the link to the page, check the columns.
I have been working on CSS for a while and have felt dire need of custom size bootstrap columns. Please consider this situation, I have a two column design for the body of my website.
<body style="background-color : grey" style="padding-right : 2% ; padding-left : 2%">
<div class="row">
<div id="col1" class="col-lg-9 style="background-color : white">
<p> Some content here</p>
</div>
<div id="col2" class="col-lg-1" style="background-color : grey"></div>
<div id="col3" class="col-lg-2" style="background-color : white">
<p>Some content here for the right column</p>
</div>
</div>
</body>
Although, I want some space between the left major column and the right major column which is done by col2, the space is too much. If i style col2 with custom width the right column shifts along breaking the standard margin from right of 2% which is clearly visible because of my footer. Therefore i need to change the widths of both col2 as well as col3.
I intend to use custom column class for lg screen size so that design stays intact on the mobile screen as well.
How do i create one? A short example would be appreciated
Thank you
How to make a space between two Bootstrap columns (on the large screen only)
Remain only two columns.
Increase the margin-left of the right column.
Decrease the width of the right column by the same value.
Use #media (min-width: 1200px).
Please check the result:
/* heart of the matter */
#media (min-width: 1200px) {
#col2 {
margin-left: 4%;
width: 21%; /* = 25% (width of .col-lg-3) - 4% (margin-left) */
}
}
/* decorations */
* {
font-size: 1.2em;
font-weight: bold;
}
#col1, #col2, #header, #footer {
margin-top: 15px;
min-height: 100px;
}
#col1, #col2 { background-color: #ccc; }
#header, #footer { background-color: #999; }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div id="header" class="col-lg-12"> Header </div>
</div>
<div class="row">
<div id="col1" class="col-lg-9"> Main content </div>
<div id="col2" class="col-lg-3"> Right column </div>
</div>
<div class="row">
<div id="footer" class="col-lg-12"> Footer </div>
</div>
</div>
I think what you're asking is simply you want to display two columns on your body which your body design is basically contains.
Other than using customized css i think bootstrap has the in-build classes to show this in view.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<body style="background-color : grey" style="padding-right : 2% ; padding-left : 2%">
<div class="row">
<div id="col1" class="col-lg-9 style="background-color : white">
<p> Some content here</p>
</div>
<div id="col2" class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="background-color : #e8e8e8">
<p>
Some content goes here </p>
</div>
<div id="col3" class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="background-color : white">
<p>Some content here for the right column</p>
</div>
</div>
</body>
Just checkout the snippet here. ids which named col2,col3 are according to your requirements. I have changed the bg.color for an instance.
And, do some customization using css for the margin, padding and other style stuffs.
And, have a look on these bootstrap grid systems and read them. They'll get the idea how to do these.
http://getbootstrap.com/css/#grid
And also you can make your web apps responsive using media queries.
https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
Hope answered your question. Happy coding!
I need to adjust Bootstrap columns to look like this.
The thing is that on smaller devices I just want to hide this blank areas on the sides, thus I don't wanna use just margins or paddings.
How can I achieve that? col-md-1 seems too small for the indents, while col-md-2 is too broad.
My Codepen with Bootstrap included.
HTML
<div class="container">
</div>
CSS
.container {
height: 230px;
background-color: blue;
max-width: 1050px;
padding-left: 15px;
padding-right: 15px;
}
If you don't want to declare any new classes padding etc. You can simply nest the columns bootply.com
Not really sure what you're trying to achieve here. The container changes it width depending on the screen size using media queries. The white/blank space you're trying to get rid off is disappearing when the size of the screen is less than 768px.
What you can do, if I understand your question correct is this option:
HTML:
<!-- CONTAINER -->
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="row">
<div class="col-md-3">
This is column nested inside
</div>
<div class="col-md-3">
This is column nested inside
</div>
<div class="col-md-3">
This is column nested inside
</div>
<div class="col-md-3">
This is column nested inside
</div>
</div>
</div>
</div>
</div>
<!-- CONTAINER FLUID -->
<div class="container-fluid">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="row">
<div class="col-md-3">
This is column nested inside
</div>
<div class="col-md-3">
This is column nested inside
</div>
<div class="col-md-3">
This is column nested inside
</div>
<div class="col-md-3">
This is column nested inside
</div>
</div>
</div>
</div>
</div>
CSS:
.container-fluid,
.container {
height: 230px;
background-color: #333;
/* max-width: 1050px; */
padding-left: 15px;
padding-right: 15px;
margin-bottom: 15px;
}
html, body {
color: #fff;
}
Couldn't you just use a #media tag to cut the padding out when in mobile view? Makes it a lot easier. Just add the class below to either your container or row.
.marginClass{
margin: 0 15px 0 15px;
}
#media screen and (min-width: 480px) {
.marginClass{
margin: 0;
}
Actually you're probably better using margin. I've updated that.
I am using older Skeleton css version, it is a 16 column grid system. I am trying to setup similar layout as in this picture.
http://imgur.com/sIV2aYo
I am pretty new to CSS, is using two containers (one inside another) a proper method?
Here is a sample code of what I been trying, but not working out too well =(
<div class="container">
<div class="eight columns alpha">
<div class="image">
<img alt="" src="images/coffee.jpg">
</div>
</div>
<div class="eight columns omega">
<div class="container">
<div class="eight columns">
<img alt="" src="images/plate.jpg">
</div>
<div class="eight columns">
<img alt="" src="images/macaro.jpg">
</div>
<div class="text area">
<p class="quote">"One of my favorite parts of using Square Register is being able to talk to customers while I am swiping their cards."</p>
<p class="name">Norm Mui, Coffee Foundry</p>
</div>
</div> <!-- 2nd container -->
</div>
</div> <!-- 1st container -->
Thanks in advance.
I don't know your CSS, but maybe this helps you:
HTML:
// The class "columns" is your "block" (div) that needs the content. I've made a CSS with a background-color, height and width.
// In that div "columns we create new "columns, numbered by 1,2 and 3. I've floated all the text to the left and gived it a margin. The first, second and the third a margin of 15px ( top, right, buttom and left ).
// In the div column "columns" I have made a textarea with also a margin of 15px. The vertical-align is for a top vertical align. with the display we means that it needs to be in the block, with a margin of 40% ( it takes 40% of the block).
<div id="container">
<div class="columns">
<div class="eight-columns-1">
<img alt="" src="http://ww1.prweb.com/prfiles/2014/04/10/11752526/gI_134971_best-image-web-hosting.png">
</div>
<div class="eight-columns-2">
<img alt="" src="http://www.causingeffect.com/images/made/images/example/cow_100_100_c1.jpg">
</div>
<div class="eight-columns-3">
<img alt="" src="http://www.causingeffect.com/images/made/images/example/cow_100_100_c1.jpg">
</div>
<div class="textarea">
<p class="quote">"One of my favorite parts of using Square Register is being able to talk to customers while I am swiping their cards."</p>
<p class="name">Norm Mui, Coffee Foundry</p>
</div>
</div>
</div>
CSS:
.columns {background-color:yellow; width: 530px; height: 285px;}
.eight-columns-1 {float:left; margin: 15px;}
.eight-columns-2 {float: left; margin: 15px;}
.eight-columns-3 {float:left; margin: 15px 15px 15px 0px;}
.textarea {vertical-align:top; margin: 15px; display:inline-block; width: 40%;}
I'm building a website using Bootstrap and I'm now trying to make something like this:
===========================================================
| #################### |
| #################### Big Title |
| ##THIS IS AN IMAGE## |
| #################### |
| #################### Read more |
===========================================================
The problem is that I can't align the ReadMore button to the bottom. I tried using the tips in this SO answer, but to no avail. I created a fiddle of my code here and I'll paste my code below.
Does anybody know what I'm doing wrong here? All tips are welcome!
My HTML looks like this:
<div class="container">
<div class="row">
<div class="col-sm-8">
<a href="/thelink">
<article class="row property-ad">
<div class="col-sm-5">
<img class="img-responsive" src="image.png">
</div>
<div class="col-sm-7">
<div class="title">Big Title</div>
<button id="read-more" class="btn btn-default pull-right">Read more</button>
</div>
</article>
</a>
</div>
<div class="col-sm-4"><div class="row"></div></div>
</div>
</div>
and my css:
#media (min-width: 768px ) {
.row {
position: relative;
}
#read-more {
position: absolute;
bottom: 0;
right: 0;
}
}
Try this:
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
#media (min-width: 768px) {
.row {
position: relative;
}
#read-more {
position: absolute;
bottom: 0;
right: 0;
}
.col-sm-7 {
position: absolute;
width: 100%;
height: 100%;
}
}
<div class="container">
<div class="row">
<div class="col-sm-12"> <a href="/thelink">
<article class="row property-ad">
<div class="col-sm-5">
<img src="//placehold.it/600x300" class="img-responsive"/>
</div>
<div class="col-sm-7">
<div class="title">Big Title</div>
<button id="read-more" class="btn btn-default pull-right">Read more</button>
</div>
</article>
</a>
</div>
</div>
</div>
Here's a fiddle
Is it what you were looking for?
Sometimes you have to work against bootstrap's floats to get what you're looking for, basically by not using them (pulls, etc). I've updated your fiddle, and I believe it's close to what you were asking. Another issue was your #media was throwing things off due to the size of the result window.
Updated Fiddle
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
.rel {
position: relative;
height:300px;
width: 600px;
}
.read-more {
position: absolute;
bottom: 0;
right: 0;
}
.background {
background-image: url("http://placehold.it/600x300");
height: 300px;
width: 600px;
}
}
<div class="container rel"> <a href="/thelink">
<article class="property-ad">
<div class="background img-responsive">
<div class="title">Big Title</div>
</div>
</article>
<button class="btn btn-default read-more">Read more</button>
</a>
</div>
This is due to the right panel only being the height of the content, in this case the title and the button.
To counter this, you need to set a height.
I added the class box-height to the html and, as the image seems to max at 141px [At least for me, W7 PC], I set the container height to that height (141px)
You can see a working example here; http://jsfiddle.net/8pLjfq5u/18/
Without the height being given, the button will just fix itself to the height of the container, which in this case is set by the title height etc.
Edit
I would advise against setting css changes in bootstrap classes in this instance.
At some point, that change to the core CSS will bite you in the behind, when you need it to work as intended in the original build.
Second Edit
It would appear that if you simply move the button into a col-sm-12 div, that you can get the desired result.
This also scales into mobile view too, without the need to add additional classes or css attributes.
http://jsfiddle.net/8pLjfq5u/20/
There are two possible problems here - depending on what exaclty you want to achieve!
(I guess it's the second one you are looking for!)
First:
if you want to position your read more at the bottom right corner of the whole page:
You have position:relative in your CSS for .row.
This means all elements inside an element with class row will be positioned relative to this element - so your read more can only be positioned inside it with your CSS (with negative values for right and bottom it can be outside, but still relative to this element).
Second:
If you want to position your read more at the the bottom right corner of the article
The parent element to your #read-more has only height of 20px, because the text Big Title in the div above is only of that height.
As your #read-more element is positioned absolute, it doesn't contribute to the height.
I tried setting height: 100%; on the parent element of #read-more, but it doesn't work.
So, it seems, you will have to put your #read-more elemnt outside of its parent div, directly into the article, like this:
<div class="container">
<div class="row">
<div class="col-sm-12">
<a href="/thelink">
<article class="row property-ad">
<div class="col-sm-5">
<img src="//placehold.it/600x300" class="img-responsive"/>
</div>
<div class="col-sm-7">
<div class="title">Big Title</div>
</div>
<button id="read-more" class="btn btn-default pull-right">Read more</button>
</article>
</a>
</div>
</div>
I added "col-xs" classes to your markup and it generated the desired display based on what you showed in your question
<div class="col-sm-5 col-xs-5">
<img src="//placehold.it/600x300" class="img-responsive"/>
</div>
<div class="col-sm-7 col-xs-7">
<div class="title">Big Title</div>
If you plug that into your fiddle it displays the way you want with your media query. When you really shrink it down though it get's pretty illegible at that point.
Maybe you want to adjust the media query to display differently for "sm" and "xs".
Try this:
<div class="d-flex justify-content-end">
<button class="btn" type="submit">Connect</button>
</div>
I'm trying to create a certain layout using bootstrap:
But unable to achieve 2 main principles in my layout:
in the first row, div 2 should be 'sticked' to the bottom of it's column (relayed on div1's height).
in the second row, i have 3 divs i want to align at center (while using bootstrap grid system!)
edit: regarding the 2nd row: i tried using 3 columns lets say 3-col for each div (since i want the margin on the right and left) but i remain with an offset of 3 more which i cant divide equally.
so i decided changing it to col-4 with a margined container, that's my solution to it:
<div class="container" style="padding: 0 80px;">
<div class="row">
<div class="col-xs-4">
<div style="border:solid 1px black;">Div1</div>
</div>
<div class="col-xs-4">
<div style="border:solid 1px black;">Div2</div>
</div>
<div class="col-xs-4">
<div style="border:solid 1px black;">Div3</div>
</div>
</div>
</div>
http://jsfiddle.net/tomico/y7xesq6v/
Hope anyone could explain how can i handle this 2 issues
Would this suffice?
.div1{position:relative;margin-top:20px;float:left;}
.div2{position:absolute;float:left;right:0px;top:40px;}
As for the 3 div row, i would wrap those three up with another div, to center just that one div containing the other three divs.
// Classes
.center-block {
display: block;
margin-left: auto;
margin-right: auto;
}
// Usage as mixins
.element {
.center-block();
}
from : Bootstrap Source
You could just use a margin-top with % for .div2
.div2 {margin-top:50%}
For your second issue what's been said above will work,
here's how the code should look:
<div class="row">
<div class="wrap">
<div class="col-xs-4">
<div style="border:solid 1px black;">Div1</div>
</div>
<div class="col-xs-4">
<div style="border:solid 1px black;">Div2</div>
</div>
<div class="col-xs-4">
<div style="border:solid 1px black;">Div3</div>
</div>
</div>
then add CSS for wrap
.wrap {width:50% ; margin:0 auto } //or 800px or whatever