I know this question has been asked before. However, I do not seem to find my mistake.
I set up a plnkr. I try to align some text vertically, whereas the the stuff that needs to be aligned is nested into multiple divs.
<div class="news col-md-12" id="detailsView" >
<div class="col-md-8 ">
<div class="row">
<div class="col-md-5 widthInDetails">
<div class="row">
<div class="col-md-8" id="newsDetails">
Hello I am fine and how are your (I am good too)
</div>
</div>
</div>
</div>
</div>
</div>
and in my CSS I have this.
.news{
background-color:black;
line-height:200px;
width:200px;
height:200px;
display:table;
}
#newsDetails{
display:table-cell;
vertical-align:middle;
}
So basically I have I lineheight given from the outer div with class="news". I want the the nested div to be aligned vertically. Is there any way to do this?
http://plnkr.co/edit/cMaCrG1Y8Ky48HwtgNPk?p=preview
If you want to use the display: table property, you should set it in the parent node, like:
<div class="news col-md-12" id="detailsView" >
<div class="col-md-8 ">
<div class="row">
<div class="col-md-5 widthInDetails">
<div id="newsParent" class="row">
<div class="col-md-8" id="newsDetails">
Hello I am fine and how are your (I am good too)
</div>
</div>
</div>
</div>
</div>
</div>
.news{
background-color:black;
width:200px;
height:200px;
}
#newsParent {
display:table;
}
#newsDetails{
height: 200px;
display:table-cell;
vertical-align:middle;
}
Give it a try and let me know if it helps!
You can make wrapper display: table and child div display: table-cell; vertical-align: middle;. find the below jsfiddle demo.
HTML
<div class="news col-md-12" id="detailsView" >
<div class="col-md-8 ">
<div class="row">
<div class="col-md-5 widthInDetails">
<div class="row newsDetailswrap">
<div class="col-md-8" id="newsDetails">
Hello I am fine and how are you?</div>
</div>
</div>
</div>
</div>
</div>
CSS
.newsDetailswrap{
background: red;
height: 100px;
display:table;
}
#newsDetails{
display: table-cell;
vertical-align: middle;
}
http://jsfiddle.net/hhbnywq1/
Related
Trying to center content within each of the two side-by-side divs.
Not sure why my content within each of these divs seems to center towards each other.
I have built a main container and two divs within it. The text is center aligned but not sure how to center the content inside of the divs.
Any ideas?
.div-header-seller-resources{
font-size:30px;
line-height:32px;
margin-bottom:10px;
}
.div-detail-seller-resources{
font-size:20px;
line-height:22px;
margin-bottom:45px;
}
.div-main-container-seller-resources{
width:100%;
}
.div-main-container-seller-resources{
margin-top:20px;
text-align: center;
display: flex;
justify-content: center;
}
.div-seller-resources-left{
width: 300px;
display: flex;
text-align:center;
}
.div-seller-resources-right{
width: 350px;
display: flex;
text-align:center;
}
.seller-resources-height{
height: 125px;
}
<div class="div-main-container-seller-resources">
<div class="div-seller-resources-left" style="display: inline-block;">
<div class="seller-resources-height">
<div class="div-header-seller-resources">How Yodega Works</div>
<div class="div-detail-seller-resources">Learn about how Yodega works for sellers</div>
</div>
<div class="clear"></div>
<div class="seller-resources-height">
<div class="div-header-seller-resources">Referrals</div>
<div class="div-detail-seller-resources">Refer another business to reduce your fees</div>
</div>
<div class="clear"></div>
<div class="seller-resources-height">
<div class="div-header-seller-resources">How to Sell with Yodega</div>
<div class="div-detail-seller-resources">Learn the best ways to promote your Yodega store</div>
</div>
<div class="clear"></div>
</div>
<div class="div-seller-resources-right" style="display: inline-block;">
<div class="seller-resources-height">
<div class="div-header-seller-resources">Setting Up Your Store</div>
<div class="div-detail-seller-resources">Detailed instructions on how to build your store</div>
</div>
<div class="clear"></div>
<div class="seller-resources-height">
<div class="div-header-seller-resources">Advanced Shipping & Product Options</div>
<div class="div-detail-seller-resources">Variable Shipping Costs, Add Product Details and More</div>
</div>
<div class="clear"></div>
<div class="seller-resources-height">
<div class="div-header-seller-resources">Order Management, Seller Dashboard & Payment</div>
<div class="div-detail-seller-resources">Detailed information on how to manage and fill orders and payments</div>
</div>
<div class="clear"></div>
</div>
</div>
<div class="seller-overview-button-container">
<button id="button2" type="button contact-button">Seller Overview</button>
</div>
Add one more outer container div and add this rule.
.container{
display:flex;
Justify-content:center;
}
And inner div
.inner {
display: flex;
flex-direction:row;
}
And the structure will be(this is pug)
div(class="container ")
div(class=" inner")
div my_left
div my_right
Set width of left and right div.
You can give CSS to the parent class text-center and for your inside or child div use margin:0px auto;.
This will result making your each child element center inside the div.
I want to create a row at the very top of a page, and another row hovering the previous one. The idea is to create two columns in the first row - col-md-3 and col-md-9, and the second row is to apply an image between those two, so the row has col-md-2, col-md-2 (image between), col-md-8. It should look like this:
I managed to create it, but the box between is still not fixed:
<div class="container-fluid">
<div style="position: absolute; width: 100%;">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-2" style="text-align: center; z-index: 9999;">
<div style="background-color: red;"> # Adding position: fixed here works but breaks box width
<img src="/assets/image/logo.jpg">
<br>
Something
</div>
</div>
<div class="col-md-8"></div>
</div>
</div>
<div class="row" style="height: 100%;">
<div class="col-md-3" style="position: relative;">
<div>
<img src="/assets/image/leftImage.jpg">
</div>
</div>
<div class="col-md-1"></div>
<div class="col-md-8">
Lorem ipsum...
</div>
</div>
</div>
How can I do that?
You dont have to use bootstrap, You can use css:
div.container
{
width:100%;
position:fixed;
background-color:red;
height:100px;
}
div.img
{
margin:auto;
width:80%;
padding:5px;
text-align:center;
}
If you check the fiddle you can understand it better.
I am trying to make 2 columns, underneath one of the column need to have 3 rows. each rows has seperate number of cells. but it's not working for me. it should 100% wide, but it look like inline-table - how to fix this?
#table {
display:table;
width:100%
}
.row {
display:table-row;
}
.cell {
display:table-cell;
border:1px solid grey;
}
.row1 {
display: table-caption;
}
.cell1 {
width:30%
}
<div id="table">
<div class="row">
<div class="cell cell1">30%</div>
<div class="cell cell2">
<div class="row row1">
<div class="cell"><h2>90%</h2></div>
<div class="cell"><h2>10%</h2></div>
</div>
<div class="row row2">
<div class="cell"><h2>40%</h2></div>
<div class="cell"><h2>20%</h2></div>
<div class="cell"><h2>20%</h2></div>
<div class="cell"><h2>20%</h2></div>
</div>
<div class="row row2">
<div class="cell"><h2>100%</h2></div>
</div>
</div>
</div>
</div>
Currently I have a row containing several divs. I'm trying to prevent the contained divs from wrapping. I also do not want a scrollbar. I've tried overflow hidden and set a width on the row.
EDIT: Constraints dictate that this must be done without tables, javascript, or external libraries.
Is there a way to do this with css without resorting to tables?
JSFiddle: http://jsfiddle.net/ozsumdfb/
HTML:
<div class="row">
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
</div>
CSS:
.square {
width:100px;
height:100px;
float:left;
margin-left:3px;
background-color: #6C6;
}
.row {
width:500px;
overflow:hidden;
}
insteed of float:left you could try display:inline-block then just add:
.row {white-space:nowrap; }
is this what you are looking for?
fiddle
Try this, I added a wrapper after row had them both with 618px since you had 6 squares padding left 3px (that is (100 + 3)*6 = 618). Hope this helps.
HTML
<div class="row">
<div class="wrapper">
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
<div class="square">
</div>
</div>
</div>
CSS
.square {
width:100px;
height:100px;
float:left;
margin-left:3px;
background-color: #6C6;
}
.row {
width:618px;
overflow-x:auto;
overflow-y:hidden;
}
.wrapper {
width: 618px;
}
I'm new to bootstrap 3. I want to divide a row into 8-column and 4-column, also add the background for the row
<div class="row" >
<div class="col-sm-8">
<div class="abc" style="background:blue">a</div>
</div>
<div class="col-sm-4">
<div class="abc" style="background:blue; border:1px solid red">b</div>
</div>
</div>
but I dont know why there is a blank space between two column. So, how can I remove the blank. Below is a image for more detail.
ps: sorry for my bad english
View Live Bootply
CSS
.row.no-gutter [class*='col-']:not(:first-child),
.row.no-gutter [class*='col-']:not(:last-child) {
padding-right:0;
padding-left:0;
}
.row.no-gutter {
margin-left: 0;
margin-right: 0;
}
HTML
<div class="row no-gutter">
<div class="col-lg-8"><div>one</div></div>
<div class="col-lg-4"><div>two</div></div>
</div>
Snap
use this
HTML
<div class="row" >
<div class="col-sm-8 paddin0 margin0">
<div class="abc" style="background:blue">a</div>
</div>
<div class="col-sm-4 paddin0 margin0">
<div class="abc" style="background:blue; border:1px solid red">b</div>
</div>
</div>
CSS
.paddin0 {
padding:0px !important
}
.margin0{
margin:0px; !important
}
I´m not bootstrap guru, what about adding blue background to parent .row instead of two children divs?
<div class="row" style="background:blue">
<div class="col-sm-8">
<div class="abc">a</div>
</div>
<div class="col-sm-4">
<div class="abc" border:1px solid red">b</div>
</div>
</div>
you can just use minus margin on that red lined div like margin-left:-30px , see demo here :
http://www.bootply.com/DDhnkOqeID
Cheers !
Just add this to your css file
.nopadding {
padding-left: 0px;
padding-right: 0px;
}
also, add that class to your column div's
having a new html code:
<div class="row" >
<div class="col-sm-8 nopadding">
<div class="abc" style="background:blue">a</div>
</div>
<div class="col-sm-4 nopadding">
<div class="abc" style="background:blue; border:1px solid red">b</div>
</div>
</div>
that will remove the padding.
Why I added a new css class?
Because you might need the default css structure of the boostrap, keeping them is a good idea and also the nopadding class can be used also to other div that you want to removed their padding.
Hope it helps.