I got give a jsfiddle that asked the following:
Four Column Layout: Using a Bootstrap class, edit these divs from stacked to a 4 column layout
HTML:
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>
<div class="c"></div>
<div class="a"></div>
<div class="d"></div>
<div class="b"></div>
CSS:
div{
height: 50px;
min-width: 50px;
}
div.a{
background: #00FF00;
}
div.b{
background: #1234FF;
}
div.c{
background: #FbbF00;
}
div.d{
background: #FF3344;
}
For my answer I did the following:
HTML:
<div class="row-fluid">
<div class="span 3">
<div class="a"></div>
<div class="b"></div>
</div>
<div class="span 3">
<div class="c"></div>
<div class="d"></div>
</div>
<div class="span 3">
<div class="c"></div>
<div class="a"></div>
</div>
<div class="span 3">
<div class="d"></div>
<div class="b"></div>
</div>
CSS:
div{
height: 50px;
min-width: 50px;
display: inline-block;
}
div.a{
background: #00FF00;
}
div.b{
background: #1234FF;
}
div.c{
background: #FbbF00;
}
div.d{
background: #FF3344;
}
But I was told I was wrong with no explanation. Does anyone know how to achieve four stacked columns using bootstrap for the above code?
Here you go with the solution https://jsfiddle.net/yczxm9px/1/
.div{
height: 50px;
}
div.a{
background: #00FF00;
}
div.b{
background: #1234FF;
}
div.c{
background: #FbbF00;
}
div.d{
background: #FF3344;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 div a">
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 div b">
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 div c">
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 div d">
</div>
</div>
</div>
All the class are bootstrap class.
xs for Extra Small Screen
sm for Small Screen
md for Medium Screen
lg for Large Screen.
Related
layout
How can i use the grid in bootstrap 4 to do the layout in the image? Can u make rows inside of a main row? I cant seem to do it.
You can use nested grid system as in the example
.b{
border: 1px black solid;
height: 50px;
margin: 5px;
}
.a{
border: 1px black solid;
height: 170px;
padding:5px;
margin:5px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="a"></div>
</div>
<div class="col-md-8 col-sm-8">
<div class="row">
<div class="col-md-12 col-sm-12">
<div class="b"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="b"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="b"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="b"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="b"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="b"></div>
</div>
<div class="col-md-4 col-sm-4">
<div class="b"></div>
</div>
</div>
</div>
</div>
HTML
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
I have managed to make vertical spaces between the columns by adding padding to the rows. But now the horizontal spaces between the contents are ways too much. How can I configure the spacing between them?
That large horizontal space is because of the fixed width of the content class if you remove that, you'll see it grow.
You can set the width of the content in % or add a margin to the content class.
.container {
text-align: center;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
}
.row{
padding:15px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-4 col4">
<div class="content">1x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x3</div>
</div>
</div>
<div class="row ">
<div class="col-md-4 col4">
<div class="content">2x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x3</div>
</div>
</div>
<div class="row col4 col4">
<div class="col-md-4 col4">
<div class="content">3x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS Grid to achieve that layout you desire:
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 5px;
position:absolute;
left:50%;
transform:translateX(-50%);
width:80%;
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height:100px;
max-width: 350px;
}
<div class="grid-container">
<div class="item">1x1</div>
<div class="item">1x2</div>
<div class="item">1x3</div>
<div class="item">2x1</div>
<div class="item">2x2</div>
<div class="item">2x3</div>
<div class="item">3x1</div>
<div class="item">3x2</div>
<div class="item">3x3</div>
</div>
Using flexbox:
.flex-container {
display: flex;
/*Generates a flexbox layout with default flex direction as row */
width: 100%;
/* Not really required */
align-items: center;
/*Aligns contents vertically */
justify-content: center;
/*Aligns contents horizontally */
text-align: center;
/*Aligns further text in the center */
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height: 400px;
width: 300px;
margin: 5px;
}
<div class="flex-container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
<div class="flex-container">
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</div>
<div class="flex-container">
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
Use float:left; with class content as below:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
float: left;
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
If I'm reading your request correctly, you are just asking how to make it look like the boxes are in the center of the page, and they are evenly spaced. see if this is what you're looking for:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.col-md-4 {
margin: 5px -10px 0px -4px;;
}
play with the numbers until you get the desired location.
Though I would strongly suggest that you add your own class in addition to col-md-4 to the boxes, which will prevent this new setting to col-md-4 from affecting any future use of this bootstrap class.
in other words . . .
CSS:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.box-move {
margin: 5px -10px 0px -4px;;
}
and HTML:
<div class="container">
<div class="row">
<div class="col-md-4 box-move">
<div class="content">1x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">2x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">3x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x3</div>
</div>
</div>
</div>
You can remove a lot of the stuff there and simplify it to make it responsive width a set margin:
.contents {
background-color: black;
color: white;
height: 500px;
margin: 20px 0px;
}
<div class="container-fluid text-center">
<div class="row">
<div class="col-md-4">
<div class="contents">1x1</div>
</div>
<div class="col-md-4">
<div class="contents">1x2</div>
</div>
<div class="col-md-4">
<div class="contents">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">2x1</div>
</div>
<div class="col-md-4">
<div class="contents">2x2</div>
</div>
<div class="col-md-4">
<div class="contents">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">3x1</div>
</div>
<div class="col-md-4">
<div class="contents">3x2</div>
</div>
<div class="col-md-4">
<div class="contents">3x3</div>
</div>
</div>
</div>
</div>
I have this HTML:
<div class="container">
<div class="box center-block">
<div class="row">
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4">
<div class="thumbnail">A</div>
</div>
</div>
</div>
</div>
And CSS:
.box {
width: 300px;
padding-top: 100px;
}
.row > div > div {
width: 100px;
height: 100px;
margin: 0px;
}
I'm also using bootsrap (version 3).
I was able to remove margin between rows, but can't remove margin between columns. Is there a way to force it somehow?
I need all "squares" next to each other without any margins (both between rows and columns).
You can see how it looks here: https://jsfiddle.net/a91zujkj/
If you really want to use col- class, make sure to set the .thumbnail elements width to 100% and use a no-padding class on the col- elements.
Here is an example:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.box {
width: 300px;
padding-top: 100px;
}
.no-padding {
padding-left: 0;
padding-right: 0;
}
.thumbnail {
width: 100%;
height: 100px;
margin: 0;
}
<div class="container">
<div class="box center-block">
<div class="row">
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 no-padding">
<div class="thumbnail">A</div>
</div>
</div>
</div>
</div>
You actually do not need to use col- classes at all and floats are not needed either. Another way to do this is using display: inline-block.
Here is how that looks:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.wrapper {
width: 300px;
padding-top: 100px;
margin: 0 auto;
font-size: 0;
}
.item {
border: 1px solid #eee;
width: 100px;
height: 100px;
display: inline-block;
font-size: initial;
}
<div class="wrapper">
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
</div>
And if you're really brave you could also use CSS Grid layout. ;)
CSS Grid Layout
CSS Grid layout excels at dividing a page into major regions, or defining the relationship in terms of size, position, and layer, between parts of a control built from HTML primitives.
Here is how that goes:
.wrapper {
padding-top: 100px;
width: 300px;
margin: 0 auto;
display: grid;
grid-template-columns: repeat(3,100px);
grid-template-rows: repeat(3,100px);
}
.item {
border: 1px solid #ddd;
height: 100px;
width: 100px;
}
<div class="wrapper">
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
<div class="item">A</div>
</div>
It's because .col-*-4 is wider than 100px, which is the width you've defined for the .thumbnail elements.
You can just remove the .col-* classes and use .pull-left instead.
.box {
width: 300px;
padding-top: 100px;
}
.row > div > div {
width: 100px;
height: 100px;
margin: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="box center-block">
<div class="row">
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
<div class="pull-left">
<div class="thumbnail">A</div>
</div>
</div>
</div>
</div>
Remove padding-left and padding-right for .col classes and then change width: 100px; to width: 100%; for .row > div > div
.box {
width: 300px;
padding-top: 100px;
}
.padding-0{
padding-right:0 !important;
padding-left:0 !important;
}
.row > div > div {
width: 100%;
height: 100px;
margin: 0px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="box center-block">
<div class="row">
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
</div>
<div class="row">
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
<div class="col-md-4 col-xs-4 padding-0">
<div class="thumbnail">A</div>
</div>
</div>
</div>
</div>
Row has it's own style and add margin to element, you can remove it by adding :
.box >.row{
margin:0;
}
I saw on http://www.webdesignerdepot.com/ that even posts have image to the right, and odd posts image to the left. This is without a doubt solved with css.
I tried to solve this with css, but without success.
This is the code i have:
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6" image>
<div class="col-xs-12 col-md-6" text>
</div>
</div>
</div>
i Want to make something like webdesignerdepot.com
Like this image i made:
Thanks for any ideas!
As others have mentioned, you can utilize CSS' float attributes, along with nth-child(odd) and nth-child(even) selectors.
Check this jsfiddle where I've used the following CSS:
.post:nth-child(odd) .row div:nth-child(odd),
.post:nth-child(even) .row div:nth-child(even) {
float: left;
height: 260px;
overflow: hidden;
width: 50%;
}
.post:nth-child(odd) .row div:nth-child(even),
.post:nth-child(even) .row div:nth-child(odd) {
float: right;
height: 260px;
overflow: hidden;
width: 50%;
}
div {
box-shadow: inset 0px 0px 1px #000;
}
Without float but display, direction will do the job for you.
display:flex;
.row .row {
display:flex;
width:400px;
height:200px;
border:red solid;
}
.row div .row >div {
flex:1;
display:flex;
align-items:center;
justify-content:center;
height:100%;
background:turquoise;
border:solid red;
direction:ltr;
}
.row .row div:nth-child(even) {
background:tomato;
}
.row :nth-child(even) .row{
direction:rtl;
}
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
Or display:table
.row .row {
display:table;
table-layout:fixed;
width:400px;
height:200px;
border:red solid;
}
.row div .row >div {
display:table-cell;
text-align:center;
vertical-align:middle;
background:turquoise;
border:solid red;
direction:ltr;
}
.row .row div:nth-child(even) {
background:tomato;
}
.row :nth-child(even) .row{
direction:rtl;
}
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6"> image</div>
<div class="col-xs-12 col-md-6"> text</div>
</div>
</div>
</div>
or display:flex and order
.row .row {
display: flex;
width: 400px;
height: 200px;
border: red solid;
}
.row div .row >div {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
background: turquoise;
border: solid red;
}
.row .row div:nth-child(even) {
background: tomato;
}
.row :nth-child(even) .row div:nth-child(even) {
order: -1
}
<div class="row">
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6">image</div>
<div class="col-xs-12 col-md-6">text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6">image</div>
<div class="col-xs-12 col-md-6">text</div>
</div>
</div>
<div class="col=xs-12 post">
<div class="row">
<div class="col-xs-12 col-md-6">image</div>
<div class="col-xs-12 col-md-6">text</div>
</div>
</div>
</div>
I can see that you're using Bootstrap. Maybe it would be worth you using their built-in .col-md-push-* and .col-md-pull-* modifier classes to swap them around.
From the Bootstrap docs:
<div class="row">
<div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
<div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
</div>
What this will result in is the two columns being reversed in order (.col-md-9 will render as coming after .col-md-3).
I would go with #krypsin's answer as you seem to be using bootstrap. But if you weren't, you could use css to do something like:
.post:nth-of-type(even) .row .col-xs-12.col-md-6:first-of-type{
float: right;
}
.post:nth-of-type(even) .row .col-xs-12.col-md-6:last-of-type{
float: left;
}
The :nth-of-type(even) applies styles to the children of every second .post class. The :last-of-type selector picks the last instance of that element type, and the :first-of-type selector applies styles to the first instance.
I have been trying to get the following done with css with no avail.
This is the closest I've gotten to something like this.
As you see, I am close, but no cigar. I need the dashes (or lines preferably, but won't get picky) are not all reaching the number. I tried taking them all the way over and use overflow:hidden, but nothing. And also, this is a responsive site so it has to respect responsiveness as well.
Here is my code. THANKS!! :
HTML
<div class="col-md-12 allocation">
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">Equities</div>
<div class="col-md-2 col-sm-2 col-xs-2">65%</div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">Domestic large capitalized firms</div>
<div class="col-md-2 col-sm-2 col-xs-2">25%</div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">Domestic small capitalized firms</div>
<div class="col-md-2 col-sm-2 col-xs-2">15%</div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">International developed markets</div>
<div class="col-md-2 col-sm-2 col-xs-2">15%</div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">International emerging markets</div>
<div class="col-md-2 col-sm-2 col-xs-2">10%</div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10"><strong>Fixed Income</strong></div>
<div class="col-md-2 col-sm-2 col-xs-2"><strong>15%</strong></div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10"><strong>Real Estate</strong></div>
<div class="col-md-2 col-sm-2 col-xs-2"><strong>20%</strong></div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">Core</div>
<div class="col-md-2 col-sm-2 col-xs-2">12.5%</div>
</div>
<div class="row">
<div class="col-md-10 col-sm-10 col-xs-10">Timber</div>
<div class="col-md-2 col-sm-2 col-xs-2">7.5%</div>
</div>
</div>
CSS:
.allocation .row{
margin:15px auto;
}
.allocation .row > div.col-md-10.col-sm-10.col-xs-10:after{
content: "--------------------------------------------------- ";
}
If you want to achieve this, you can check the code here or here:
<div class="col-xs-12">
<div class="row">
<div>Equities</div>
<div>65%</div>
</div>
<div class="row">
<div>Domestic large capitalized firms</div>
<div>25%</div>
</div>
<div class="row">
<div>Domestic small capitalized firms</div>
<div>15%</div>
</div>
<div class="row">
<div>International developed markets</div>
<div>15%</div>
</div>
<div class="row">
<div>International emerging markets</div>
<div>10%</div>
</div>
<div class="row">
<div><strong>Fixed Income</strong></div>
<div><strong>15%</strong></div>
</div>
<div class="row">
<div><strong>Real Estate</strong></div>
<div><strong>20%</strong></div>
</div>
<div class="row">
<div>Core</div>
<div>12.5%</div>
</div>
<div class="row">
<div>Timber</div>
<div>7.5%</div>
</div>
</div>
With this css code:
.row {
border-bottom: 1px dashed black;
height: 15px;
clear: right;
margin-bottom: 16px;
}
.row div:first-of-type {
float: left;
background: #FFF;
padding-right: 5px;
}
.row div:last-of-type {
float: right;
margin-top: 1px;
background: #FFF;
width: 50px;
text-align: right;
}
There are several solutions for this... here is one:
.index-row{
border-bottom: 1px dashed;
height:1.5em;
clear:both;
}
.index-row h2, .index-row span{
padding:5px;
margin:0;
line-height:1.0em;
background:white;
}
.index-row h2{
float:left;
}
.index-row span{
float:right;
}
<div>
<div class="index-row">
<h2>titulo indice</h2>
<span>45</span>
</div>
<div class="index-row">
<h2>titulo indice</h2>
<span>45</span>
</div>
<div class="index-row">
<h2>titulo indice</h2>
<span>45</span>
</div>
</div>
Simple and responsive solution using grid:
.index-item {
display: grid;
justify-content: space-between;
align-items: baseline;
grid-template-columns: auto 1fr auto;
gap: .5rem;
padding-block: .5rem;
}
.index-line {
height: 3px;
min-width: 15px;
background: linear-gradient(90deg, #888 2.5%, #fff 2.5%, #fff 47.5%, #888 47.5%, #888 52.5%, #fff 52.5%, #fff 97.5%, #888 97.5%);
background-size: 10px 10px;
background-position: 50px 50px;
}
<div class="index-item">
<div class="index-title">Page Title</div>
<span class="index-line"></span>
<div class="index-number">200</div>
</div>
<div class="index-item">
<div class="index-title">Page Title (long title)</div>
<span class="index-line"></span>
<div class="index-number">230</div>
</div>