expected
I'm trying set 100% height in the nested row with the code below:
<div class="row">
<div class="col-md-4">
<!--This is not working-->
<div style="height:100%">
First Column, First Cell
</div>
</div>
<div class="col-md-8">
<div class="row">
<div class="col-xs-12">
Second Column, First Cell
</div>
<div class="col-xs-12">
Second Column, Second Cell
</div>
<div class="col-xs-12">
Second Column, Third Cell
</div>
</div>
</div>
</div>
But it output as
output
You can use Bootstrap Tables instead of rows and columns.
UPD. I've added coloured outlines for cells.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style>
td {
border: 0 !important;
outline: 4px solid;
outline-offset: -8px;
padding: 16px !important;
}
.red-box {
outline-color: red;
}
</style>
<div class="container">
<table class="table">
<tr>
<td rowspan="3" class="red-box">First Column, First Cell</td>
<td>Second Column, First Cell</td>
</tr>
<tr>
<td>Second Column, Second Cell</td>
</tr>
<tr>
<td>Second Column, Third Cell</td>
</tr>
</table>
</div>
I would suppose you're doing it in two column layout, you can do that using bootstrap by setting the parent div with height so that.
<div style="height=100%;">
First Column, First Cell
</div>
has the basis of 100% property,
For example:
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-6" style="height: 100px;">
<div class="row" style="height: 100px;">
<div class="col-md-12" style="height: 100px;">
<div style="height:100%;border: 1px solid black;">
First Column, First Cell
</div>
</div>
</div>
</div>
<div class="col-md-6" style="height: 100px;border: 1px solid black;">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-xs-12">
Second Column, First Cell
</div>
<div class="col-xs-12">
Second Column, Second Cell
</div>
<div class="col-xs-12">
Second Column, Third Cell
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Hope this help
Related
im trying to split row (col-md-12 = full width of row) for 3 parts - col-md-8 + col-md-2 + col-md-2, but bootstrap class col doesn't work as it shoud and im getting 3x columns sticked 2 each other :(
<!-- Bootstrap 4 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<!-- Body -->
<body style="background-color:gray; margin: 0">
<div class="container-fluid" style="height: 5%; background-color: green;">
<div>
<div class="row form-inline">
<div class="col-md-8" style="display: inline-block">something</div>
<div class="col-md-2" style="display: inline-block">something2</div>
<div class="col-md-2" style="display: inline-block">something3</div>
</div>
</div>
</div>
</body>
What I'm getting:
What I want to get:
PS:
I know that i can use style width 70% + 15% + 15% but i think it s not the point of using bootstrap :/
Assuming based on your screenshot, it looks like your device width is less than 768px. If that is, therefore it works as expected in your screenshot since you're using col-md - Read more about bootstrap's responsive breakpoints here
If you do not want to make it responsive, then you should just use col-{n}. Read more about Bootstrap 4 grid options
E.g.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<h5> Current approach </h5>
<div class="container-fluid" style="height: 5%; background-color: #cfcfcf;">
<div>
<div class="row form-inline">
<div class="col-md-8" style="display: inline-block">col-md-8</div>
<div class="col-md-2" style="display: inline-block">col-md-2</div>
<div class="col-md-2" style="display: inline-block">col-md-2</div>
</div>
</div>
</div>
<br />
<br />
<h5> Expected approach </h5>
<div class="container-fluid" style="height: 5%; background-color: #a0a0a0;">
<div>
<div class="row form-inline">
<div class="col-8" style="display: inline-block">col-8</div>
<div class="col-2" style="display: inline-block">col-2</div>
<div class="col-2" style="display: inline-block">col-2</div>
</div>
</div>
</div>
I am trying to put 5 div elements next to each other and also center them. However, I cant make it work. Here is my code
<div style="width:200px;margin-right:20px;">
<div class="panel panel-default text-center" style="border: 1px solid #fab05d;border-radius:0px;">
<div class="panel-heading" style="background-color:#fab05d;color:#ffffff !important;border-radius:0px;">
<h1>2017</h1>
<p style="line-height: 14pt; margin-top:3px;margin-right:25px;">EARLY BIRD*</p>
<p style="clear:both;line-height: 16pt;">GOLD PACKAGE <br>REGISTRATION**</p>
</div>
<div class="panel-body" style="padding-top:5px;">
<p style="color:#929393;font-size:15px;"><strong>$x.00 TICKET</strong></p>
<div style="display:inline-block;margin:auto;padding-top:1px;margin-top:1px;" class="text-center">
<input type="image" src="http://localhost/wordpress/wp-content/uploads/2017/03/gold_remove.png" id="gold_r" style="">
<input type="text" class="text-center" id='goldval' name="quantity" size="5" onchange="gold_change()" style="vertical-align:top;font-weight:bold;border-radius:5px;border:1px solid #929393;">
<input type="image" src="http://localhost" id="gold_a" style="">
</div>
</div>
</div>
I have 5 of them. They are basically the same, only the content is different. All 5 divs are inside container-fluid (I am using bootsrap). I have tried to add display:inline-block to my container but it doesn't work. Also, I used float:left but in that case, I can't properly align my divs when the screen size changes. I tried to use the extended version of Bootstrap grid when you can create equal 5 columns but in that case, my div's content gets messed up. Can anyone please give me some solution that will work for all screen sizes? Thanks
Try this in a larger screen, I think this will work. The snippet's screen is very small that's why it does not align together. Use Media Queries to adjust the div's size so that it can accommodate smaller screen size
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
</div>
</div>
This may help you!
.col-xs-2{
background:green;
color:#FFF;
}
.col-half-offset{
margin-left:4.166666667%
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row" style="border: 1px solid black">
<div class="col-xs-2" id="p1">One</div>
<div class="col-xs-2 col-half-offset" id="p2">Two</div>
<div class="col-xs-2 col-half-offset" id="p3">Three</div>
<div class="col-xs-2 col-half-offset" id="p4">Four</div>
<div class="col-xs-2 col-half-offset" id="p5">Five</div>
<div>lorem</div>
</div>
</div>
I am using Skeleton Framework, and the layout I made using the grid system is like this:
<div class="container">
<!-- columns should be the immediate child of a .row -->
<div class="row">
<div class="three columns">
<br>
</div>
<div class="six columns" style="margin-top: 25px">
<img src="img/okay.jpg" width="50px" style="display:inline"/>
<p id="title" style="display:inline">{{title}}</p>
<p id="excerpt" style="display:inline">{{description}}</p>
<div id="describe me" style="display:inline"><span style="display:inline">{{name}}</span><span style="display:inline">{{date}}</span></div>
</div>
<div class="three columns">
<br>
</div>
</div>
</div>
It shows something like this:
But what I want is something like this:
How can this be achieved?
Result:
Responding to your code, although there are many alternate solutions for this, maybe even in their documentation.
First, try to avoid using inline styles.
Wrap your content inside a
class.
Vetical align the image to the top.
Remove the default margin
on the paragraph items.
.desc {
display: inline-block;
}
.desc p {
margin-bottom: 0;
}
.six img {
vertical-align: top;
}
<link href="//cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" rel="stylesheet" />
<div class="container">
<!-- columns should be the immediate child of a .row -->
<div class="row">
<div class="three columns">
<br>
</div>
<div class="six columns">
<img src="http://placehold.it/50x75" width="50px" />
<div class="desc">
<p id="title">{{title}}</p>
<p id="excerpt">{{description}}</p>
<div id="describe me"><span>{{name}}</span><span>{{date}}</span>
</div>
</div>
</div>
<div class="three columns">
<br>
</div>
</div>
</div>
I'm using foundations grid. I've got a grid with two columns and would like to have the content of the right column scale to 100% the height of the left column.
I made a JSBin to illustrate my problem (you have to open the output in a seperate tab for some reasons).
That is how it looks:
div {
border: 1px solid #CCC;
}
<link href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/css/normalize.min.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/css/foundation.min.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/js/vendor/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.3/js/foundation.min.js"></script>
<div class="row" style="width:50%">
<div class="small-8 columns">
<div class="row">
left column first row
</div>
<div class="row">
left column second row
</div>
<div class="row">
left column third row
</div>
<div class="row">
left column fourth row
</div>
<div class="row">
left column fifth row
</div>
<div class="row">
left column sixth row
</div>
<div class="row">
left column seventh row
</div>
<div class="row">
left column eigth row
</div>
<div class="row">
left column ninth row
</div>
</div>
<div class="small-4 columns">
<div class="row">
this is supposed to scale to 100% of the size of the left column
</div>
</div>
</div>
Try like this: Demo
CSS:
div {
border: 1px solid #CCC;
}
#row_box{
display:table;
}
.child{
display:table-cell;
background-color:red;
}
.child:nth-child(2)
{
background-color:yellow;
}
HTML:
<div class="row" style="width:50%">
<div id="row_box"> // added id row_box
<div class="large-8 child"> // added class child & removed columns
<div class="row">
left column first row
</div>
<div class="row">
left column second row
</div>
<div class="row">
left column third row
</div>
<div class="row">
left column fourth row
</div>
</div>
<div class="large-4 child"> // added class child & removed columns
<div class="row">
this is supposed to scale to 100% of the size of the left column
</div>
</div>
</div>
</div>
Note:
This -ve margin is coming from your css file.
I am trying to create a background color for my row, yet when I set a background color it extends over the regular width of my columns.
Then I tried making the row smaller with padding, which works, but makes the columns smaller.
I need to somehow remove the pink area, keep only the red background, AND keep the columns even.
Any ideas?
<!-- When applying the padding, the columns background turns OK. However, the
columns themselves aren't as even as "normal" columns without padding -->
<div class="row" style="background-color: pink; padding-right: 15px; padding-left: 15px; ">
<div class="large-3 columns" style="background-color: red;">
text1
</div>
<div class="large-3 columns" style="background-color: red;">
text2
</div>
<div class="large-3 columns" style="background-color: red;">
text3
</div>
<div class="large-3 columns" style="background-color: red;">
text4
</div>
</div>
<!-- The background of the columns is same for all of the columns, and it's
bigger than the image because of the padding -->
<div class="row">
<div class="large-3 columns" style="background-color: teal;">
text1
</div>
<div class="large-3 columns" style="background-color: teal;">
text2
</div>
<div class="large-3 columns" style="background-color: teal;">
text3
</div>
<div class="large-3 columns" style="background-color: teal;">
text4
</div>
</div>
<!-- This image has a padding in the column, so it's not the whole width of
the row -->
<div class="row">
<div class="large-12 columns" style="background-color: grey;">
<img alt="slide image" src="http://placehold.it/1000x15">
</div>
</div>
One way is to remove column padding as this causes you to see the pink background in the row div and add margin for row to have them aligned.
.columns{
padding-left: 0rem;
padding-right: 0rem;
}
.row{
margin-left: 0.83333rem;
margin-right: 0.83333rem;
width:auto;
}
Here is a Fiddle