I want to try to make a div page with an icon around the text and button but it won't make an icon beside the text just like this(It also affects the button). I already tried using Flex documentation d-flex justify-content-around in div class but it doesn't work. I'm using Bootstrap 4. Here's the result :
The Result:
The Result I wanted:
Here's the coding :
Home.html
div.page {
padding: 10px 20px;
background: #FDFDFD;
width: 280px;
height: 180px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 32px;
}
p.page {
color: #252525;
margin-left: 20px;
font-size: 30px;
font-weight: bold;
font-family: 'Roboto',sans-serif;
}
button.show {
border-radius: 32px;
font-weight:bold;
margin-right: 80px;
margin-top: 30px;
border: 3px solid #3379E4;
text-align:center;
padding: 5px;
background: #3379E4;
width: 50%;
color: #FDFDFD;
font-family:'Roboto', sans-serif;
}
i.page {
font-size: 36px;
color: #3379E4;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
<div class="container mt-5">
<div class="row">
<div class="col text-center">
<div class="d-flex">
<div class="page mr-auto p-2">
<i class="page fas fa-calculator text-right"></i>
<p class="page text-left">AK</p>
<button class="show">Show</button>
</div>
<div class="page p-2">
<i class="page fas fa-laptop text-right"></i>
<p class="page text-left">TKJ</p>
<button class="show">Show</button>
</div>
</div>
<img src="https://cdn.pixabay.com/photo/2016/09/18/14/21/swimmer-1678307__340.jpg" class="img-fluid" width="500">
<div class="d-flex">
<div class="page mr-auto p-2">
<i class="page fas fa-store text-right"></i>
<p class="page text-left">PM</p>
<button class="show">Show</button>
</div>
</div>
</div>
</div>
</div>
Thank you for helping.
I add custom css that you could see by the bottom of the css:
/**** CSS ADDED ****/
.img-fluid {
margin: -10vh auto;
}
.z-index-1{
z-index:1;
}
I recommand to not use class: .img-fluid as I did but to create another class with this negative margin. Here it is really just for the demo
Then I added classes in follow:
<div class="col text-center">
<div class="d-flex">
To make it like:
<div class="col text-center d-flex flex-column">
<div class="d-flex z-index-1">
Edit:
Rework structure of your card this way by dividing in 2 cols and some correction in CSS for icon font-size :
<div class="page p-2 row">
<div class="col-8">
<p class="page text-left">TKJ</p>
<button class="show">Show</button>
</div>
<div class="col-4 d-flex">
<i class="page fas fa-laptop m-auto"></i>
</div>
</div>
DEMO:
div.page {
padding: 10px 20px;
background: #FDFDFD;
width: 280px;
height: 180px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 32px;
}
p.page {
color: #252525;
margin-left: 20px;
font-size: 30px;
font-weight: bold;
font-family: 'Roboto',sans-serif;
}
button.show {
border-radius: 32px;
font-weight:bold;
margin-right: 80px;
margin-top: 30px;
border: 3px solid #3379E4;
text-align:center;
padding: 5px;
background: #3379E4;
width: 100%; /* CAHNGED FROM 50% TO 100% */
color: #FDFDFD;
font-family:'Roboto', sans-serif;
}
i.page {
font-size: 4em; /* Changed from 36px to 4em */
color: #3379E4;
}
/**** CSS ADDED ****/
.img-fluid {
margin: -10vh auto;
}
.z-index-1{
z-index:1;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
<div class="container mt-5">
<div class="row">
<div class="col text-center d-flex flex-column">
<div class="d-flex z-index-1">
<div class="page mr-auto p-2 row">
<div class="col-8">
<p class="page text-left">AK</p>
<button class="show">Show</button>
</div>
<div class="col-4 d-flex">
<i class="page fas fa-calculator m-auto"></i>
</div>
</div>
<div class="page p-2 row">
<div class="col-8">
<p class="page text-left">TKJ</p>
<button class="show">Show</button>
</div>
<div class="col-4 d-flex">
<i class="page fas fa-laptop m-auto"></i>
</div>
</div>
</div>
<img src="https://cdn.pixabay.com/photo/2016/09/18/14/21/swimmer-1678307__340.jpg" class="img-fluid" width="500">
<div class="d-flex z-index-1">
<div class="page mr-auto p-2 row">
<div class="col-8">
<p class="page text-left">PM</p>
<button class="show">Show</button>
</div>
<div class="col-4 d-flex">
<i class="page fas fa-store m-auto"></i>
</div>
</div>
</div>
</div>
</div>
</div>
Related
I am working on bootstrap grid which is as follows:
.facevalue {
background: #ffffff61;
font-family: Dubai;
font-size: 18px;
font-weight: 400;
line-height: 30px;
padding: 0 30px;
border: 1px solid #e9e9e9;
margin: 1px 0;
}
.faceid {
background: #dcdcdc;
font-family: Dubai;
font-size: 18px;
font-weight: 500;
line-height: 30px;
padding: 0 30px;
border: 1px solid #e9e9e9;
margin: 1px 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row no-gutters">
<div class="col-md-6">
<div class="row no-gutters">
<div class="col-md-3">
<div class="faceid">Name</div>
</div>
<div class="col-md-9">
<div class="facevalue">ABC</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row no-gutters">
<div class="col-md-3">
<div class="faceid">DOB</div>
</div>
<div class="col-md-9">
<div class="facevalue">11/12/2020</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row no-gutters">
<div class="col-md-3">
<div class="faceid">About Me</div>
</div>
<div class="col-md-9"><textarea class="facevalue w-100 p-1" type="text" id="myComment" rows="1" cols="50" value="">About me text....... </textarea>
</div>
</div>
</div>
</div>
I want the output for columns which should look like similar to each rows as per image.
How to achieve to combining the first column of second row? So it will show output as shown in image.
.facevalue {
background: #ffffff61;
font-family: Dubai;
font-size: 18px;
font-weight: 400;
line-height: 30px;
padding: 0 30px;
border: 1px solid #e9e9e9;
margin: 1px 0;
}
.faceid {
background: #dcdcdc;
font-family: Dubai;
font-size: 18px;
font-weight: 500;
line-height: 30px;
padding: 0 30px;
border: 1px solid #e9e9e9;
margin: 1px 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="row no-gutters">
<div class="col-sm-3">
<div class="faceid">Name</div>
</div>
<div class="col-sm-3">
<div class="facevalue">ABC</div>
</div>
<div class="col-sm-3">
<div class="faceid">DOB</div>
</div>
<div class="col-sm-3">
<div class="facevalue">11/12/2020</div>
</div>
</div>
<div class="row no-gutters">
<div class="col-sm-3">
<div class="faceid">About Me</div>
</div>
<div class="col-sm-9"><textarea class="facevalue w-100 p-1" type="text" id="myComment" rows="1" cols="50" value="">About me text....... </textarea>
</div>
</div>
I am having a problem on putting a border on the left most part of a section outside a container. I tried putting a margin-left on the container-fluid but the line should be inline with the section only. Right now the line is in the blue line. Please see image for better explanation.
Here's the current code
.store_details_item_wrapper {
padding-left: 20px;
border-left: 10px solid blue;
}
.store_details_img_wrapper {
border: 5px solid black;
height: 100px;
width: 100px;
margin-bottom: 15px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="section-wrapper">
<div class="container">
<div class="row store_details_row">
<div class="store_details col col-md-4 order-12 order-md-1">
<div class="store_details_img_wrapper">
<img class="store_details_img" media={props.fields.logo} />
</div>
<div class="store_details_item_wrapper">
<div class="store_details_item">
<i class="fa fa-clock" />
Text here
</div>
<hr />
<div class="store_details_item">
<i class="fa fa-parking" />
Text here
</div>
</div>
</div>
<div class="store_description col-12 col-md-8 order-1 order-md-12">
<Image
class="store_description_banner img-fluid"
media={props.fields.herobanner}
/>
</div>
</div>
</div>
</div>
Since you have used border-left this is 1 solution.
or you can use position: absolute and left with negative values to .store_details_item_wrapper
.store_details_item_wrapper {
padding-left: 60px;
border-left: 10px solid blue;
margin-left: -70px;
}
.store_details_img_wrapper {
border: 5px solid black;
height: 100px;
width: 100px;
margin-bottom: 15px;
}
.container-fluid{
border: 2px solid black;}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container-fluid">
<div class="container">
<div class="row store_details_row">
<div class="store_details col col-md-4 order-12 order-md-1">
<div class="store_details_img_wrapper">
<img class="store_details_img" media={props.fields.logo} />
</div>
<div class="store_details_item_wrapper">
<div class="store_details_item">
<i class="fa fa-clock" /> Text here
</div>
<hr />
<div class="store_details_item">
<i class="fa fa-parking" /> Text here
</div>
</div>
</div>
<div class="store_description col-12 col-md-8 order-1 order-md-12">
<Image class="store_description_banner img-fluid" media={props.fields.herobanner} />
</div>
</div>
</div>
</div>
I am working on a budgeting app, and I am trying to make something that looks like a bunch of tiles (below). However I am getting stuck, because when I go to put content in the tiles, the content sticks to the bottom.
I am using bootstrap 4, and I have been able to make some square divs, and style them to my liking (thanks SO), but I just can't add anything to them. How would I solve this?
(also on a related/unrelated note when I put m-2 on the divs it bumps the rightmost div down a row)
.squareBox:before{
padding-top: 100%;
/* makes expand to a square */
content: '';
width: 0;
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 mt-4">
<div class="row">
<div class="col-sm-4 squareBox icon m-2">
<div class="row">
<div class="col-xs-6">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
</div>
</div>
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
</div>
</div>
<div class="col-md-6 mt-4"></div>
</div>
</div>
What it currently looks like:
What it needs to look like:
I would use a different method to make the boxes square. Use a margin "dummy" div, and place the squareBox inside the columns...
.dummy {
margin-top: 100%;
}
.squareBox {
background: #1A3967;
color: #fff;
border-radius: 10px;
position: absolute;
top: 30px;
bottom: 0;
left: 30px;
right: 0;
}
Then you can put whatever is needed inside each box, using Bootstrap 4 flexbox utils to position it.
Demo: https://www.codeply.com/go/MZrc2ELjIG
You could try the flexbox approach :)
.squareBox{
/* makes expand to a square */
width: 200px;
height: 200px;
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
max-width: 200px;
}
.justify-start {
align-self: flex-start !important;
}
.t-1 {
font-size: 1.2rem;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="m-5 d-flex justify-content-center align-items-center">
<div class="squareBox icon d-flex flex-column justify-content-between align-items-center m-2">
<div class="d-flex align-self-start justify-content-between w-100 p-2">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
<p class="font-weight-bold text-muted">$XX.X</p>
</div>
<div class="d-flex justify-content-center align-items-center text-white text-center">
<p class="font-weight-bold t-1">Netflix & Hulu With roommcomm</p>
</div>
<div class="d-flex align-self-start justify-content-around w-100 text-white">
<p>Sorted</p>
<p>3</p>
</div>
</div>
<div class="squareBox icon d-flex flex-column justify-content-between align-items-center m-2">
<div class="d-flex align-self-start justify-content-between w-100 p-2">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
<p class="font-weight-bold text-muted">$XX.X</p>
</div>
<div class="d-flex justify-content-center align-items-center text-white text-center">
<p class="font-weight-bold t-1">End of The F****** World</p>
</div>
<div class="d-flex align-self-start justify-content-around w-100 text-white">
<p>Sorted</p>
<p>5</p>
</div>
</div>
</div>
also, here's a working example :)
On a side note, I modified your squareBox class's width and height to give it dimensions :)
On the other hand, you can apply the flex-wrap class on the parent container so the stuff inside it that doesn't fit in a given row will go to the next row instead
You would want to set the icon to absolute and set to top with a bit of left and top offset.
If you're not gonna make these 'icon'-looking-things as image. then you have to rely heavily on absolute positioning.
.squareBox:before {
padding-top: 100%;
/* makes expand to a square */
content: '';
width: 0;
white-space: normal;
display: inline-block;
vertical-align: middle;
max-width: 100%;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.icon .row {
position: absolute;
top: 5px;
left: 20px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 mt-4">
<div class="row">
<div class="col-sm-4 squareBox icon m-2">
<div class="row">
<div class="col-xs-6">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
</div>
</div>
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
</div>
</div>
<div class="col-md-6 mt-4"></div>
</div>
</div>
Rather than using padding-top: 100%; to define the dimensions of square box
, add height and width.
.squareBox{
width: 100px;
height: 100px;
padding: 5px;
}
.icon {
font-family: lato;
background: #1A3967;
border-radius: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-md-6 mt-4">
<div class="row">
<div class="col-sm-4 squareBox icon m-2">
<div class="row">
<div class="col-xs-6">
<img src="https://s3.amazonaws.com/rkersey-test-assets/netflix.png" height="20px" />
</div>
</div>
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
<div class="col-sm-4 squareBox m-2">
first square box.
</div>
</div>
</div>
<div class="col-md-6 mt-4"></div>
</div>
</div>
The navigation bar is at a certain distance away from the top, after scrolling past the navigation-bar, it sticks to the top but unfortunately it's width expands beyond the container(it's defined in). The navigation-bar should retain it's original width, so how do I resolve it? Here's my github link too :- https://github.com/Archiie/MyPortfolio
.affix {
top: 0px;
margin: 0px 20px;
}
.affix + .container {
padding: 5px;
}
h1, h4 {
text-shadow: 4px 5px 3px #A866B2; /*#DCD4F9, #F74554 moves to the right, moves down, thickness of text's shadow*/
}
.main-container {
margin: 40px 0px;
border-radius: 10px;
background-color: #4B004C ; /*#800000, #4B004C, #E6E6E6*/
}
#head_tag, #footer_tag {
font-family: Tangerine, Monospace;
color: white;
}
#head_tag {
font-size: 100px;
height: 300px;
}
#footer_tag {
font-size: 50px;
}
.image {
border-style: solid;
border-radius: 50%;
border-width: 1px;
border-color: #000;
height: 230px;
width: 240px;
}
.img-responsive {
margin: 20px auto;
}
.navbar {
margin: 0px 20px;
z-index: 1;
}
.info {
font-family: Monospace;
font-size: 20px;
background-color: #E6E6E6; /*#4B004C, #E6E6E6*/
border-radius: 10px;
margin: 20px 20px;
padding: 20px 20px;
}
.boxSpacing {
margin: 20px auto;
}
.pics {
height: 300px;
width: 300px;
}
#aboutMe, #portfolio, #contactMe {
font-family: Lobster, Monospace;
font-size: 35px;
color: #6E326F;
}
.centeringIcon {
display: block;
text-align:center;
color: white;
}
<!DOCTYPE html>
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body data-spy="scroll" data-target=".navbar" data-offset="10">
<div class="container main-container">
<div class="row">
<div class="col-md-8">
<h1 class="text-center" id="head_tag">Archita's Portfolio</h1>
</div>
<div class="col-md-4">
<img src="images/Archi.jpg" class="img-responsive image">
</div>
</div>
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="365">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse" id="myNavbar"> <!-- This navigation bar should not change it's width even after scrolling past it-->
<ul class="nav navbar-nav">
<li>About Me</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</nav>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="info">
<h3 class="text-center" id="aboutMe">About Me</h3>
<p>I'm a new-bee in front-end technology. I used to work on ROR, R and Python but now I'm exploring HTML, CSS, Bootstrap, jQuery, JavaScript, AngularJS and ReactJS.</p>
<p>I've also worked on several <span style="color:#960099">android projects </span>as well. I've also worked on highcharts and D3.</p>
</div>
<div class="info">
<h3 class="text-center" id="portfolio">Portfolio</h3>
<div class="row">
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
</div>
</div>
<div class="info">
<h3 class="text-center" id="contactMe">Contact</h3>
<p><b>Here's my contact details:</b></p>
<ul>
<li>Name:- Archita Sundaray</li>
<li>Phone no.:- +91 89514 88208</li>
<li>email address:- archi.sundaray5#gmail.com</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<h4 class="text-center" id="footer_tag">~ made by Archita Sundaray</h4>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-linkedin centeringIcon"></i>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-github centeringIcon"></i>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-twitter centeringIcon"></i>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-bitbucket centeringIcon"></i>
</div>
</div>
</div>
</body>
</html>
Check Now its working, when it is sticky then it's position fixed so you have to give it width or set left and right position
.affix {
top: 0px;
margin: 0px 20px;
width:1100px;
}
#media (max-width: 1199px)
{
.affix {
width: 900px;
}
}
#media (max-width: 991px)
{
.affix {
width: 680px;
}
}
#media (max-width: 768px)
{
.affix {
left:15px;
right:15px;
width:auto;
}
}
.affix + .container {
padding: 0px;
}
h1, h4 {
text-shadow: 4px 5px 3px #A866B2; /*#DCD4F9, #F74554 moves to the right, moves down, thickness of text's shadow*/
}
.main-container {
margin: 40px 0px;
border-radius: 10px;
background-color: #4B004C ; /*#800000, #4B004C, #E6E6E6*/
}
#head_tag, #footer_tag {
font-family: Tangerine, Monospace;
color: white;
}
#head_tag {
font-size: 100px;
height: 300px;
}
#footer_tag {
font-size: 50px;
}
.image {
border-style: solid;
border-radius: 50%;
border-width: 1px;
border-color: #000;
height: 230px;
width: 240px;
}
.img-responsive {
margin: 20px auto;
}
.navbar {
margin: 0px 20px;
z-index: 1;
}
.info {
font-family: Monospace;
font-size: 20px;
background-color: #E6E6E6; /*#4B004C, #E6E6E6*/
border-radius: 10px;
margin: 20px 20px;
padding: 20px 20px;
}
.boxSpacing {
margin: 20px auto;
}
.pics {
height: 300px;
width: 300px;
}
#aboutMe, #portfolio, #contactMe {
font-family: Lobster, Monospace;
font-size: 35px;
color: #6E326F;
}
.centeringIcon {
display: block;
text-align:center;
color: white;
}
<!DOCTYPE html>
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body data-spy="scroll" data-target=".navbar" data-offset="10">
<div class="container main-container">
<div class="row">
<div class="col-md-8">
<h1 class="text-center" id="head_tag">Archita's Portfolio</h1>
</div>
<div class="col-md-4">
<img src="images/Archi.jpg" class="img-responsive image">
</div>
</div>
<div class="row">
<div class="col-md-12">
<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="365">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse" id="myNavbar"> <!-- This navigation bar should not change it's width even after scrolling past it-->
<ul class="nav navbar-nav">
<li>About Me</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</nav>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="info">
<h3 class="text-center" id="aboutMe">About Me</h3>
<p>I'm a new-bee in front-end technology. I used to work on ROR, R and Python but now I'm exploring HTML, CSS, Bootstrap, jQuery, JavaScript, AngularJS and ReactJS.</p>
<p>I've also worked on several <span style="color:#960099">android projects </span>as well. I've also worked on highcharts and D3.</p>
</div>
<div class="info">
<h3 class="text-center" id="portfolio">Portfolio</h3>
<div class="row">
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
<div class="col-md-6 boxSpacing">
<img src="images/Project_1.png" class="img-responsive pics">
</div>
</div>
</div>
<div class="info">
<h3 class="text-center" id="contactMe">Contact</h3>
<p><b>Here's my contact details:</b></p>
<ul>
<li>Name:- Archita Sundaray</li>
<li>Phone no.:- +91 89514 88208</li>
<li>email address:- archi.sundaray5#gmail.com</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<h4 class="text-center" id="footer_tag">~ made by Archita Sundaray</h4>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-linkedin centeringIcon"></i>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-github centeringIcon"></i>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-twitter centeringIcon"></i>
</div>
<div class="col-md-1 img-responsive">
<i class="fa fa-bitbucket centeringIcon"></i>
</div>
</div>
</div>
</body>
</html>
I am trying to have two columns in a navigation bar in bootstrap. But when I do, and I try resizing, the right column overlaps the left. I can't understand why. I see the problem arising from viewport size 769px and persists upto 992px.
HTML
.site-wrapper {
width: 100%;
height: 100%;
min-height: 100%;
-webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5);
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
border-top: 5px solid #5A332B;
background-color: #ccbb99 !important;
overflow-y: auto;
}
.navbar {
border-radius: 0;
border: none;
background-color: #683F36;
}
.navbar-brand {
cursor: pointer;
color: #ffffff !important;
font-family: chalkitup, "sans-serif";
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="site-wrapper">
<div class="navbar navbar-default">
<div class="container-fluid" style="background-color: #8c8c8c;">
<div class="row">
<div class="col-md-9" style="background-color: #1b6d85;">
<div class="navbar-header">
<a class="navbar-brand"><span class="icon ion-arrow-left-c"></span> Back</a>
</div>
</div>
<div class="col-md-3" style="background-color: #3c763d;">
Scoreboard
</div>
</div>
</div>
</div>
Try below code
<div class="site-wrapper">
<div class="navbar navbar-default">
<div class="container-fluid" style="background-color: #8c8c8c;">
<div class="row">
<div class="col-md-9 col-xs-12" style="background-color: #1b6d85;">
<div class="navbar-header">
<a class="navbar-brand"><span class="icon ion-arrow-left-c"></span> Back</a>
</div>
</div>
<div class="col-md-3 col-xs-12" style="background-color: #3c763d;">
Scoreboard
</div>
</div>
</div>
</div>
I have added working example here
.site-wrapper {
width: 100%;
height: 100%;
min-height: 100%;
-webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5);
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
border-top: 5px solid #5A332B;
background-color: #ccbb99 !important;
overflow-y: auto;
}
.navbar {
border-radius: 0;
border: none;
background-color: #683F36;
}
.navbar-brand {
cursor: pointer;
color: #ffffff !important;
font-family: chalkitup, "sans-serif";
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="site-wrapper">
<div class="navbar navbar-default">
<div class="container-fluid" style="background-color: #8c8c8c;">
<div class="row">
<div class="col-md-9 col-xs-12" style="background-color: #1b6d85;">
<div class="navbar-header">
<a class="navbar-brand"><span class="icon ion-arrow-left-c"></span> Back</a>
</div>
</div>
<div class="col-md-3 col-xs-12" style="background-color: #3c763d;">
Scoreboard
</div>
</div>
</div>
</div>
Alright, I eventually found the answer to my own question. I had to add the clearfix class to the first column in the row. Although it fixed my issue, still would like to know if there are any other views.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="site-wrapper">
<div class="navbar navbar-default">
<div class="container-fluid" style="background-color: #8c8c8c;">
<div class="row">
<div class="col-sm-9 col-md-9" style="background-color: #1b6d85;">
<div class="navbar-header">
<a class="navbar-brand"><span class="icon ion-arrow-left-c"></span> Back</a>
</div>
</div>
<div class="col-sm-3 col-md-3" style="background-color: #3c763d;">
Scoreboard
</div>
</div>
</div>
</div>
You missed to use col-sm-... for small devices