I am trying to align the text and icons, which are in a box, to the center of it. I want it centered like this:
I tried the following:
adding align-content: center and justify-content: center as an inline style in the div tag for row, but no luck. Any helps or leads are appreciated. I have provided a jsfiddle link to show you what I have now. As of now, all the content is left.
https://jsfiddle.net/silosc/76ktyveu/4/
<div class="row" style="width:100%">
<div class="report-card-i report-card-i-height">
<h3 class="m-l-35 p-t-25 p-b-10">Stats</h3>
<div class="fa-orange m-t-10 m-b-15">
<div class="row">
<div class="col-sm-3 col-xs-3">
<i class="fa fa-star m-r-15">Stat1</i>
</div>
<div class="col-sm-2 col-xs-3">
<i class="fa fa-angle-right"></i>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-3 col-xs-3">
<i class="fa fa-star m-r-15">Stat2</i>
</div>
<div class="col-sm-2 col-xs-3">
<i class="fa fa-angle-right"></i>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-3 col-xs-3">
<i class="fa fa-star m-r-15">Stat3</i>
</div>
<div class="col-sm-2 col-xs-3">
<i class="fa fa-angle-right"></i>
</div>
</div>
</div>
</div>
</div>
<style>
.report-card-i{
background: orange;
box-shadow: 2px 2px 10px 4px rgba(0, 0, 0, 0.2);
position: relative;
margin-top: 30px;
}
.report-card-i-height {
min-height: 280px;
height: auto;
width: 100%;
}
.report-name {
font-family: Questrial;
font-weight: bold;
color: #f0522f !important;
}
</style>
Since you are using bootstrap you can use the text-left class. Also a lot of your bootstrap margins and padding classes are set wrong... margins are mr-1 to mr-5. Same format for paddings
.report-card-i {
background: orange;
box-shadow: 2px 2px 10px 4px rgba(0, 0, 0, 0.2);
position: relative;
margin-top: 30px;
}
.report-card-i-height {
min-height: 280px;
height: auto;
width: 100%;
}
.report-name {
font-family: Questrial;
font-weight: bold;
color: #f0522f !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row" style="width:100%">
<div class="report-card-i report-card-i-height">
<h3 class="ml-5 pt-5 pb-2">Stats</h3>
<div class="fa-orange mt-5 mb-5">
<div class="row">
<div class="col-sm-3 col-xs-3 text-center">
<i class="fa fa-star">Stat1</i>
</div>
<div class="col-sm-2 col-xs-3">
<i class="fa fa-angle-right"></i>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-3 col-xs-3 text-center">
<i class="fa fa-star m-r-15">Stat2</i>
</div>
<div class="col-sm-2 col-xs-3">
<i class="fa fa-angle-right"></i>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-3 col-xs-3 text-center">
<i class="fa fa-star m-r-15">Stat3</i>
</div>
<div class="col-sm-2 col-xs-3">
<i class="fa fa-angle-right"></i>
</div>
</div>
</div>
</div>
</div>
Try this: .fa { margin-left: 50%; transform: translateX(-50%); },
and if you want space between the icon and the text then try: .fa-star:before { padding-right: 20px; }
Related
I have a horizontal scrollable div where I have squared divs. I need to make these squared divs bigger, but I can't achieve this. In the example I provide here, there are 3 squared divs. Each time I add a new one, all of them get even smaller. How can I prevent them from shrinking and maintain my scrollable div?
Here's my codepen.
Set a min-width to your boxes, and make sure your container doesn't wrap.
Modified code is in the bottom of the CSS snippet
.publish-product-form {
margin-bottom: 15px;
}
.image-scroller {
border: 1px solid blue;
width: 375px;
height: auto;
white-space: nowrap;
position: relative;
overflow-x: scroll;
overflow-y: hidden;
background-color: white;
padding: 0px;
-webkit-overflow-scrolling: touch;
}
.img-box {
padding: 0px;
}
.img-holder {
margin-top: 20px;
}
.image-doesnt-exist {
width: 100%;
padding-bottom: 100%;
background-size: cover;
background-position: center;
border: 2px dotted #8ABE57;
border-radius: 0.25rem;
}
.add-img-button::before {
font-size: 1.2em;
}
.add-img-button {
color: #8ABE57;
position: absolute;
top: 50%;
left: 50%;
font-size: 1.2em;
transform: translate(-50%, -50%);
}
.add-img-button:hover {
color: #9FD362;
}
/**New css**/
.image-scroller .row {
flex-wrap: nowrap;
}
.image-scroller .img-box {
min-width: 180px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.4.3/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-alpha1/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.1/css/all.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-primary" type="button" data-toggle="modal" data-target="#editProductModal">Click me</button>
<!-- Modal Editar Aviso -->
<div class="modal fade bd-example-modal-md publish-product-modal" tabindex="-1" role="dialog"
aria-labelledby="myLargeModalLabel" aria-hidden="true" id="editProductModal">
<div class="modal-dialog modal-md modal-dialog-centered" role="document">
<div class="modal-content publish-product-modal-content">
<div class="modal-header publish-product-modal-header">
<img src="images/logo-header.svg">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body publish-product-modal-body text-center col-lg-11 col-md-11 pb-5 pt-0 mx-auto">
<!-- Image Edition Section -->
<div class="publish-product-form col-12">
<form class="edit-ad-product-information">
<!--- MY IMAGE SCROLL TEST -->
<div class="row">
<div class="image-scroller col-12">
<div class="row">
<div class="img-box col">
<div class="col-12 img-holder">
<a href="#">
<i class="fas fa-camera add-img-button"></i>
<div class="image-doesnt-exist"></div>
</a>
</div>
</div>
<div class="img-box col">
<div class="col-12 img-holder">
<a href="#">
<i class="fas fa-camera add-img-button"></i>
<div class="image-doesnt-exist"></div>
</a>
</div>
</div>
<div class="img-box col">
<div class="col-12 img-holder">
<a href="#">
<i class="fas fa-camera add-img-button"></i>
<div class="image-doesnt-exist"></div>
</a>
</div>
</div>
<div class="img-box col">
<div class="col-12 img-holder">
<a href="#">
<i class="fas fa-camera add-img-button"></i>
<div class="image-doesnt-exist"></div>
</a>
</div>
</div>
<div class="img-box col">
<div class="col-12 img-holder">
<a href="#">
<i class="fas fa-camera add-img-button"></i>
<div class="image-doesnt-exist"></div>
</a>
</div>
</div>
<div class="img-box col">
<div class="col-12 img-holder">
<a href="#">
<i class="fas fa-camera add-img-button"></i>
<div class="image-doesnt-exist"></div>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- /MY IMAGE SCROLL TEST-->
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /Modal Editar Aviso-->
remove col class from div.img-box,
also you need to change .row class' display property to block from flex
.row {
display: block;
white-space: nowrap
}
.img-box {
height: 125px;
width: 125px;
display: inline-block;
}
Been researching and adjusting the following code, but aligning the text with even spacing is eluding me. I am able to accomplish this easily with a table element, but I want to master Flex Box methods. Any help appreciated.
Screen Shot of text-alignment issue:
#navbar-menu-button-mobile,
#navbar-container-mobile {
display: flex !important;
}
/* === Navigation Drop-down Menu === */
#navbar-container-mobile {
margin-top: 74px;
padding: 0 1%;
background: white;
}
.navbar-menu-item-mobile {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<div id="navbar-container-mobile" class="container">
<div id="navbar-collapse-mobile" class="collapse w-100">
<div class="navbar-menu-item-mobile">
<div class="fa fa-calendar"></div><div class="pr-2"></div><div>Calendar</div>
</div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-compass"></div><div class="pr-2"></div><div>Locations</div>
</div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-heartbeat"></div><div class="pr-2"></div><div>Physicians</div>
</div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-random"></div><div class="pr-2"></div><div>Trades</div>
</div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-user"></div><div class="pr-2"></div><div>Personal</div>
</div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-cog"></div><div class="pr-2"></div><div>Settings</div>
</div>
<div class="dropdown-divider"></div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-sign-out"></div><div class="pr-2"></div><div>Sign Out</div>
</div>
</div>
</div>
Example below assuming that you're using FontAweosme v4, Please follow this Markup:
<div class="navbar-menu-item-mobile">
<i class="menu icons"></i>
<div>Menu label</div>
</div>
And you need to set width, margin to the icons:
.navbar-menu-item-mobile .fa {
width: 15px;
margin-right: 10px;
}
Example:
#navbar-menu-button-mobile,
#navbar-container-mobile {
display: flex !important;
}
/* Add this */
.navbar-menu-item-mobile .fa {
width: 15px;
margin-right: 10px;
}
/* === Navigation Drop-down Menu === */
#navbar-container-mobile {
margin-top: 74px;
padding: 0 1%;
background: white;
}
.navbar-menu-item-mobile {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="navbar-container-mobile" class="container">
<!-- Removed collapse class for testing -->
<div id="navbar-collapse-mobile" class="w-100">
<div class="navbar-menu-item-mobile">
<i class="fa fa-calendar"></i>
<div>Calendar</div>
</div>
<div class="navbar-menu-item-mobile">
<i class="fa fa-compass"></i>
<div>Locations</div>
</div>
<div class="navbar-menu-item-mobile">
<i class="fa fa-heartbeat"></i>
<div>Physicians</div>
</div>
<div class="navbar-menu-item-mobile">
<i class="fa fa-random"></i>
<div>Trades</div>
</div>
<div class="navbar-menu-item-mobile">
<i class="fa fa-user"></i>
<div>Personal</div>
</div>
<div class="navbar-menu-item-mobile">
<div class="fa fa-cog"></div>
<div>Settings</div>
</div>
<div class="dropdown-divider"></div>
<div class="navbar-menu-item-mobile">
<i class="fa fa-sign-out "></i>
<div>Sign Out</div>
</div>
</div>
</div>
You need to give a min-width to your icons
While zooming the page TEXT is overlapping with the Image, I am sharing my screenshot, Please look into that and can you please give me the solution.
Thanks in Advance...
This is the css Code, While zooming the page TEXT is overlapping with the Image,
.Pad{
padding: 60px 0px;
margin-top: -300px;
}
body {
margin: 0;
}
.outer-div-for-the-imgae-icon{position:relative; display:block; height:300px; width:300px; }
.outer-div-for-the-imgae-icon img{height:300px; width:300px; object-fit:cover;}
.outer-div-for-the-imgae-icon i{position:absolute; top:0; left:100%; font-size:40px;}
This is the HTML code, While zooming the page TEXT is overlapping with the Image,
<div class="col-12 col-12 p-0">
<div class="col-6 float-left">
<div class="outer-div-for-the-imgae-icon">
<app-image [imagesrc]="imagePath" style="width: 190px;max-height: 190px;clip-path: square(25px at center);"
class="d-none d-sm-block" alt="..."></app-image>
<i (click)="inputFile.click()" style="color : white;left: 180px;
position: absolute; top: -5px; padding: 3px; background-color: rgb(0, 195, 255);
border-radius: 50%;font-size: 12px;"
class="fa fa-pencil fa-lg" aria-hidden="true"></i>
</div>
<div class="col-6 Pad float-right">
<div class="col-sm ">
<span class="name">
<b style="color: rgb(25,25,112); font-size : 15px ">{{myprofile?.FirstName}}
{{myprofile?.LastName}}</b>
</span>
</div>
<div class="col-sm">
<span class="name">
<p>{{myprofile?.Role}}</p>
</span>
</div>
<div class="col-sm">
<span class="name">
<p>{{myprofile?.Phone}} {{myprofile?.UserName}}</p>
</span>
</div>
</div>
</div>
<!-- end snippet -->
Hi sandeep please try this and replace this css in you css and let me know if its fine.please adjust the min and max width and height according to you.
.outer-div-for-the-imgae-icon{position:relative; display:block; min-height:300px; width:100%; height:auto;} .outer-div-for-the-imgae-icon img{max-height:300px; width:100%; max-width:300px; height:auto; object-fit:cover;} .outer-div-for-the-imgae-icon i{position:absolute; top:0; left:100%; font-size:40px;}
I think this is overlapping only because we have given the image a fixed width and height .
EDIT:
so i've changed the code a bit and this is what you will need:
<style>
.Pad{
padding: 60px 0px;
margin-top: -300px;
}
body {
margin: 0;
}
.outer-div-for-the-imgae-icon{position:relative; display:block; height:300px; width:300px; }
.outer-div-for-the-imgae-icon img{height:300px; width:300px; object-fit:cover;}
.outer-div-for-the-imgae-icon i{position:fixed; top:0; left:100%; font-size:40px;}
</style>
<html>
<body>
<div class="col-12 col-12 p-0">
<div class="col-6 float-left">
<div class="outer-div-for-the-imgae-icon">
<app-image [imagesrc]="imagePath" style="width: 190px;max-height: 190px;clip-path: square(25px at center);"
class="d-none d-sm-block" alt="..."></app-image>
<i (click)="inputFile.click()" style="color : white;left: 180px;
position: absolute; top: -5px; padding: 3px; background-color: rgb(0, 195, 255);
border-radius: 50%;font-size: 12px;"
class="fa fa-pencil fa-lg" aria-hidden="true"></i>
</div>
<div class="col-6 Pad float-right">
<div class="col-sm ">
<span class="name">
<b style="color: rgb(25,25,112); font-size : 15px ">{{myprofile?.FirstName}}
{{myprofile?.LastName}}</b>
</span>
</div>
<div class="col-sm">
<span class="name">
<p>{{myprofile?.Role}}</p>
</span>
</div>
<div class="col-sm">
<span class="name">
<p>{{myprofile?.Phone}} {{myprofile?.UserName}}</p>
</span>
</div>
</div>
</div>
<div id="over" >
<img src="https://stepupandlive.files.wordpress.com/2014/09/3d-animated-frog-image.jpg"> some text
</div>
<div style="padding-left: 100px;" class="col-6 float-right">
<div class="col-12 ">
<div class="office-address-heading">
<p class="Address">Office Address</p>
</div>
<div class="d-flex align-items-center">
<!-- <i style="color:grey;" class="fa fa-map-marker fa-2x mr-2" aria-hidden="true"></i> -->
<address class="mb-0 size">
{{myprofile?.OfficeAddress}}
</address>
</div>
</div>
<hr />
<div class="col-12">
<div class="office-address-heading">
<p class="Address">Communication Details</p>
</div>
<div class="d-flex align-items-center office-address-details ">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style ="right: 14px;">
<div class="col-xs-12 col-sm-12 col-md-5 col-lg-5 float-left">
<i class="fa fa-phone fa-2x mr-2" aria-hidden="true"></i>
<a style="color: black;" href="tel:1-562-867-5309">{{myprofile?.Phone}}</a>
</div>
<div class="d-flex1 col-xs-12 col-sm-12 col-md-8 col-lg-7 align-items-center office-address-details float-right ">
<i class="fa fa-envelope fa-2x mr-2" aria-hidden="true"></i>
<a style="color: black;" href="mailto:rafael.cepeda#lpl.com">{{myprofile?.Email}}</a>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
which you will get this result:
enter image description here
what i have changed is removing the css from the div that is responsible for the image, (bear in mind that i don't have the required files like photo's, links ect.... but this changed the image not overlapping the text.
reply if there is something wrong or if you have any questions
I've looked at this answer and a few similar ones, but still struggling with alignment.
I have 3 divs in a parent div. Each div has a font-awesome icon and text.
Currently the alignment is spaced evenly horizontally, but with gaps between text and icons. I need each div's text next to the icon.
What I have:
[ icon text icon text icon text ]
What I need:
[ icon text icon text icon text ]
Code:
.question-instructions {
background-color: #3eb6a9;
margin: 0px 0px 0px;
}
.question-line {
margin: 0px auto;
white-space: nowrap;
text-align: center;
}
.question-block {
margin: 10px 0 30px;
align-content: center;
vertical-align: middle;
/*display: inline-block; */
}
.block1 {
/* float: left;*/
}
.block2 {
/*display:inline-block;*/
}
.block3 {
/*float: right;*/
}
<div class="container">
<div class="row">
<div class="question-instructions">
<div class="row text-center">
<div class="col-lg-8 col-lg-offset-2 col-md-8 col-md-offset-2 col-sm-8 col-sm-offset-2 ">
<h2>MY TITLE</h2>
</div>
</div>
<div class="row question-line">
<div class="col-lg-4 col-md-4 col-sm-4 question-block block1">
<div class="pull-left"><i class="fa fa-group fa-fw fa-3x question-icon"></i>
</div>
<h4>My first text</h4>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 question-block block2">
<a class="pull-left" href="#">
<i class="fa fa-question fa-fw fa-3x question-icon"></i>
</a>
<h4 class="">My second text</h4>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 question-block block3">
<div class="pull-left"><i class="fa fa-graduation-cap fa-fw fa-3x question-icon"></i>
</div>
<h4>My third text</h4>
</div>
</div>
</div>
</div>
</div>
I've tried:
adding float left and right to the two divs on the ends and switching the html around so the floats are first and then the centre. Didn't work.
If I remove the text-align: center css property from the .question-line then the text is against the icons how it should be, but everything is then left aligned in the parent div and not centered. I get this then:
[ icon text icon text icon text ]
I've tried display: table-cell on the icons and the h4. also not working.
I made a few changes in your code, see code bellow :
.question-instructions {
background-color: #3eb6a9;
margin: 0px 0px 0px;
}
.question-line {
margin: 0px auto;
white-space: nowrap;
text-align: center;
}
.question-block {
margin: 10px 0 30px;
align-content: center;
vertical-align: middle;
/*display: inline-block; */
}
.block1 {
/* float: left;*/
}
.inline-block {
display: inline-block;
}
.block3 {
/*float: right;*/
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="question-instructions">
<div class="row text-center">
<div class="col-lg-8 col-lg-offset-2 col-md-8 col-md-offset-2 col-sm-8 col-sm-offset-2 ">
<h2>MY TITLE</h2>
</div>
</div>
<div class="row question-line">
<div class="col-lg-4 col-md-4 col-sm-4">
<i class="fa fa-group fa-fw fa-3x question-icon"></i>
<h4 class="inline-block">My first text</h4>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 ">
<i class="fa fa-question fa-fw fa-3x question-icon"></i>
<h4 class="inline-block">My second text</h4>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 ">
<i class="fa fa-graduation-cap fa-fw fa-3x question-icon"></i>
<h4 class="inline-block">My third text</h4>
</div>
</div>
</div>
</div>
</div>
Here is updated code. text-align did the trick. Check in "full page" mode to see the effect. http://i.imgur.com/KAYkTMp.png
.question-instructions {
background-color: #3eb6a9;
margin: 0px 0px 0px;
width: 100%;
}
.question-line {
margin: 0px auto;
white-space: nowrap;
text-align: center;
}
.question-block {
margin: 10px 0 30px;
vertical-align: middle;
white-space: nowrap;
}
.block1 {
/* float: left;*/
}
.block2 {
/*display:inline-block;*/
}
.block3 {
/*float: right;*/
}
<div class="container">
<div class="row">
<div class="question-instructions">
<div class="row text-center">
<div class="col-lg-12 col-lg-offset-2 col-md-8 col-md-offset-2 col-sm-8 col-sm-offset-2 ">
<h2>MY TITLE</h2>
</div>
</div>
<div class="row question-line">
<div class="col-lg-4 col-md-4 col-sm-4 question-block block1">
<div style="display: inline-block;">
<i class="fa fa-group fa-fw fa-3x question-icon pull-left"></i>
<h4 class="pull-left">My first text</h4>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 question-block block2">
<div style="display: inline-block;">
<i class="fa fa-question fa-fw fa-3x question-icon pull-left"></i>
<h4 class="pull-left">My second text</h4>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 question-block block3">
<div style="display: inline-block;">
<i class="fa fa-graduation-cap fa-fw fa-3x question-icon pull-left"></i>
<h4 class="pull-left">My third text</h4>
</div>
</div>
</div>
</div>
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
Check this fiddle.
CSS
.question-instructions {
background-color: #3eb6a9;
margin: 0px 0px 0px;
}
.question-line {
margin: 0px auto;
white-space: nowrap;
text-align: left;
}
.question-block {
margin: 10px 0 30px;
align-content: center;
vertical-align: middle;
}
.question-block h4{
display: inline-block;
}
.block {
float: left;
}
I have a set of four coloumns like so:
<div class="container-fluid" id="skills">
<div class="row">
<div class="col-md-3 col-xs-6 border">
<i class="fa fa-terminal"></i>
<br>
Linux
</div>
<div class="col-md-3 col-xs-6 border">
<i class="fa fa-html5"></i>
<br>
HTML5
</div>
<div class="col-md-3 col-xs-6 border">
<i class="fa fa-cogs"></i>
<br>
Teamwork
</div>
<div class="col-md-3 col-xs-6">
<i class="fa fa-bullhorn"></i>
<br>
Communication
</div>
</div>
</div>
CSS is:
#skills #border {
border-right: 1px solid #ddd;
}
This produces:
However, when the screen is re-sized to 768px (xs) it looks like
.
What can I do to make it have borders only on the inside of the columns?
if you want to have less class names and be able to use it for more than 4 items you can use this.
#skills .border:not(:first-child){
border-left: 1px solid #ddd;
}
#media (max-width: 992px){
#skills .border:nth-child(odd){
border-left: none;
}
#skills .border:nth-child(n+3){
border-top: 1px solid #ddd;
}
}
html:
<div id="skills" class="row">
<div class="col-md-3 col-xs-6 border" >
<i class="fa fa-terminal"></i>
<br>
Linux
</div>
<div class="col-md-3 col-xs-6 border" >
<i class="fa fa-html5"></i>
<br>
HTML5
</div>
<div class="col-md-3 col-xs-6 border">
<i class="fa fa-cogs"></i>
<br>
Teamwork
</div>
<div class="col-md-3 col-xs-6 border">
<i class="fa fa-bullhorn"></i>
<br>
Communication
</div>
</div>
Fiddle
If you want it dynamic with less css code, try this out
.border{
padding: 40px;
border-bottom: 1px solid #CCC;
border-right: 1px solid #CCC;
}
/*xs*/
#media(max-width:767px){
.border{
border-right: none;
}
}
/*sm*/
#media(max-width:991px){
.border:nth-child(2n){
border-right: none;
}
}
/*md*/
#media(min-width:992px){
.border:nth-child(4n){
border-right: none;
}
}
Check Demo Here https://jsfiddle.net/adratarek/q8kec8xb/4/
Invalid usage of Id #border. ID can not repet as per HTML rules.
You should use class if you want to use it multiple times.
HTML
<div class="row">
<div class="col-md-3 col-xs-6 border" >
<i class="fa fa-terminal"></i>
<br>
Linux
</div>
<div class="col-md-3 col-xs-6 border" >
<i class="fa fa-html5"></i>
<br>
HTML5
</div>
<div class="col-md-3 col-xs-6 border">
<i class="fa fa-cogs"></i>
<br>
Teamwork
</div>
<div class="col-md-3 col-xs-6">
<i class="fa fa-bullhorn"></i>
<br>
Communication
</div>
</div>
CSS
#skills .border {
border-right: 1px solid #ddd;
}
Demo
EDIT:
According to your need (as you specified in comment).
HTML
<div class="row">
<div class="col-md-3 col-xs-6 border-right" >
<i class="fa fa-terminal"></i>
<br>
Linux
</div>
<div class="col-md-3 col-xs-6 " >
<i class="fa fa-html5"></i>
<br>
HTML5
</div>
<div class="col-md-3 col-xs-6 border-top border-right">
<i class="fa fa-cogs"></i>
<br>
Teamwork
</div>
<div class="col-md-3 col-xs-6 border-top">
<i class="fa fa-bullhorn"></i>
<br>
Communication
</div>
</div>
CSS
#skills .border-right {
border-right: 1px solid #ddd;
}
#skills .border-top {
border-top: 1px solid #ddd;
}
Demo
Okay, fixed this with some media queries jsfiddle
Media query is
#media (min-width: 992px) {
#skills .border-right-md {
border-right: 1px solid #ddd;
}
#skills .border-top {
border-top: none;
}
}