Why do my grid columns wrap to a second line? - css

I have 3 buttons using Bootstrap 4. I have defined them each to be 4 columns of the grid, so I figured they would all stay on 1 row. However the 3rd button is dropping down to the next line and I can't figure out why.
I've made a codepen here: https://codepen.io/xanabobana/pen/pobRxpx
HTML:
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-4 button button-header button-tools-collections"><h3>Tools</h3> <span class="badge"><span class="fa fa-wrench fa-2x"></span></span></div>
<div class="col-12 col-md-4 button button-header button-tools-collections"><h3>Collections</h3> <span class="badge"><span class="fa fa-folder-open fa-2x"></span></span></div>
<div class="col-12 col-md-4 button button-header button-tools-collections"><h3>Regional Projects</h3> <span class="badge"><span class="fa fa-globe fa-2x"></span></span></div>
</div></div>
CSS:
.button-header {
border: 3px solid #b8d87a;
display: inline-block;
font-size: .8em;
margin: 2em 1em 2em 0;
}
.button-header a {
color: #fff;
padding: .5em 1em;
display: block;
}
.button-header a:hover {
text-decoration: none;
background-color: rgba(255, 255, 255, 0.3);
}
.button-header .arrow {
font-family: arial;
}
.button-tools-collections a {
color: black;
text-align: center;
}

You've put styles on the columns that make them wider. That's not a good practice. Use layout elements for layout and put elements inside those for styling.
<div class="col-12 col-md-4">
<div class="button button-header button-tools-collections">
<a href="<?php echo site_url('products/tools/'); ?>">
<h3>Tools</h3>
<span class="badge"><span class="fa fa-wrench fa-2x"></span></span>
</a>
</div>
</div>

Related

Using Bootstrap Grid, Why Can I Not Space Out My Divs?

I'm working on my first web dev portfolio and am trying to incorporate the Bootstrap Grid system to the project links. I've searched through Bootstrap's documentation (v4.5), Stack Overflow, and just googling various searches to death. I've tried every solution I've found and am still getting nowhere. The closest I've come to a result is changing all three col-lg-4 to col-lg33. That did create the space, but then the padding looked super weird and it was more space than I needed. Any help would be super appreciated. I'm a but of a noob still.
<section id="projects">
<h2>My Work</h2>
<div class="container">
<div class="row justify-content-around">
<div class="col-lg-4 col-md-6 projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project"/>
<p class="project-title">CSS Technical Document</p>
</a>
</div>
<div class="col-lg-4 col-md-6 projects-grid">
<a href="https://briafly27.github.io/Javascript30DrumKit/" target="_blank">
<img class="project-image" src="Images/JavascriptDrumkit.png" alt="project"/>
<p class="project-title">Javascript Drumkit</p>
</a>
</div>
<div class="col-lg-4 col-md-6 projects-grid">
<a href="https://briafly27.github.io/FirstPersonalSite/" target="_blank">
<img class="project-image" src="Images/FirstPersonalSite.png" alt="project"/>
<p class="project-title">First Personal Site</p>
</a>
</div>
</div>
</div>
</section>
#projects {
background: #3F3F44;
color: #f7f7f7;
font-family: 'Raleway', sans-serif;
height: 100vh;
}
#projects h2 {
text-shadow: 1px 1px #fdcb9e;
text-align: center;
padding: 60px;
}
.projects-grid {
background-color: #fdcb9e;
box-shadow: 5px 8px black;
border-radius: 10px;
padding: 1% 0;
}
.projects-grid:hover {
background-color: #cceabb;
box-shadow: 7px 10px black;
}
.projects-grid a {
text-decoration: none;
color: #3f3f44;
text-shadow: 1px 1px #cceabb;
}
.project-image {
height: 100%;
max-height: 170px;
width: 100%;
max-width: 300px;
border-radius: 10px;
border: 2px solid #cceabb;
display: flex;
margin: 0 auto;
}
.project-image:hover {
border: 2px solid #fdcb9e;
}
.project-title {
font-size: 1.5rem;
font-weight: 700;
padding-top: 8px;
padding-bottom: 4px;
margin: 0;
text-align: center;
}
Bootstrap is adding the column guttering as a 15px padding, by styling the layout there, you are also styling the padding that is the guttering, hence the project grid 'cards' are touching.
For this, to keep the guttering and to ensure nice even columns, I would style a nested div instead.
<div class="col-md-4">
<div class="projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project" />
<p class="project-title">CSS Technical Document</p>
</a>
</div>
</div>
If the guttering is too large, you can change the sass variable (it's set to 30px by default) or you can use .no-gutters to remove all the guttering and add the padding manually to the nested divs.
<div class="row no-gutters">
<div class="col-md-4 p-2">
<div class="projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project" />
<p class="project-title">CSS Technical Document</p>
</a>
</div>
</div>
</div>
I've created this link on Codepen to try understanding better the problem so that we can help you better:
https://codepen.io/maricaldas/pen/ExPKNzM
<section id="projects">
<h2>My Work</h2>
<div class="container">
<div class="row justify-content-around">
<div class="col-lg-3 col-md-6 projects-grid">
<a href="https://briafly27.github.io/TechnicalDocumentAssignment/" target="_blank">
<img class="project-image" src="Images/TechnicalDoc.png" alt="project" />
<p class="project-title">CSS Technical Document</p>
</a>
</div>
<div class="col-lg-3 col-md-6 projects-grid">
<a href="https://briafly27.github.io/Javascript30DrumKit/" target="_blank">
<img class="project-image" src="Images/JavascriptDrumkit.png" alt="project" />
<p class="project-title">Javascript Drumkit</p>
</a>
</div>
<div class="col-lg-3 col-md-6 projects-grid">
<a href="https://briafly27.github.io/FirstPersonalSite/" target="_blank">
<img class="project-image" src="Images/FirstPersonalSite.png" alt="project" />
<p class="project-title">First Personal Site</p>
</a>
</div>
</div>
</div>
</section>
Do you mean you want a space separating the project-grid columns?
If so, the first thing we need to consider is that when we use 3 columns taking 4 spaces each, we're using the full grid, which is 12, and that's why we can't see spaces around those col-lg-4 columns.
Can you please elaborate a little bit more on the result you want to achieve?
Maybe a way to add that space among the columns while using col-lg-4 is to overwrite the bootstrap pre-set width, which is 33.33%.
#media (min-width: 992px) {
.col-lg-4 {
-ms-flex: 0 0 32%;
flex: 0 0 32%;
max-width: 32%;
}
}

create table from divs with hidden rows with CSS

I have created a table of divs with CSS that is made up of parent rows and child rows, but I want the child rows to make them visible or to hide with the help of vuejs. My problem is not how to make them visible / hidden, how to properly align parents with children.
In my example the child row should fit between parent row two and three, but the child row is displayed above the parent row with the number three.
In the example below the irregularities can be seen much better in full screen mode.
Thanks!
.div-table {
display: table;
width: 100%;
table-layout: auto;
font-size: 12px;
color: black;
}
.div-table-head {
display: table-header-group;
background: #e5e5e5;
vertical-align: middle;
}
.div-table-body {
display: table-row-group;
vertical-align: middle;
}
.div-table-tr {
display: table-row;
}
.div-table-th {
display: table-cell;
font-weight: 700;
text-transform: uppercase;
border-bottom: 3px solid #666;
}
.div-table-td {
display: table-cell;
border-bottom: 1px solid #e5e5e5;
}
.div-table-th, .div-table-td {
padding: 6px;
}
.div-table-tr:nth-of-type(odd) {
background: #f8f8f8;
border-top: 1px solid #e5e5e5;
border-bottom: 1px solid #e5e5e5;
}
.div-table-tr:hover {
background: #ffd;
}
.my-material-icons {
font-size: 13px;
color: gray;
cursor: pointer;
}
.col-span {
position: absolute;
padding: 0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.3.1/css/uikit.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css" rel="stylesheet"/>
<div class='div-table'>
<div class='div-table-head'>
<div class='div-table-th' style="width: 3%">#</div>
<div class='div-table-th' >th2</div>
<div class='div-table-th' >th3</div>
</div>
<div class='div-table-body'>
<!-- parent -->
<div class='div-table-tr'>
<div class='div-table-td'>1 <i title="title" class="material-icons my-material-icons">arrow_drop_down_circle</i></div>
<div class='div-table-td'>td12</div>
<div class='div-table-td'>td13</div>
</div>
<!-- parent -->
<div class='div-table-tr'>
<div class='div-table-td'>2 <i title="title" class="material-icons my-material-icons">arrow_drop_down_circle</i></div>
<div class='div-table-td'>td22</div>
<div class='div-table-td'>td23</div>
</div>
<!-- child -->
<div class='div-table-tr'>
<div class='div-table-td col-span'>
<div class='div-table'>
<div class='div-table-head'>
<div class='div-table-th' style="width: 4%">#</div>
<div class='div-table-th' >th2</div>
<div class='div-table-th' >th3</div>
</div>
<div class='div-table-body'>
<div class='div-table-tr'>
<div class='div-table-td'>1 <i title="title" class="material-icons my-material-icons">arrow_drop_down_circle</i></div>
<div class='div-table-td'>td12</div>
<div class='div-table-td'>td13</div>
</div>
<div class='div-table-tr'>
<div class='div-table-td'>2 <i title="title" class="material-icons my-material-icons">arrow_drop_down_circle</i></div>
<div class='div-table-td'>td22</div>
<div class='div-table-td'>td23</div>
</div>
</div>
</div>
</div>
</div>
<!-- parent -->
<div class='div-table-tr'>
<div class='div-table-td'>3 <i title="title" class="material-icons my-material-icons">arrow_drop_down_circle</i></div>
<div class='div-table-td'>td32</div>
<div class='div-table-td'>td33</div>
</div>
</div>
</div>
Firts of all instead of use div labels to build a table you should use the vuejs markup https://v2.vuejs.org/v2/examples/grid-component.html

Semantic UI Sidebar height is larger than viewport size

Example JSFiddle: https://jsfiddle.net/eqf8wwxe/
I'm trying to use the Semantic UI sidebar with a footer. However, the height of the page is not greater than the view-port by the height of the footer.
How can I go about correcting this? What is causing this in this situation?
$('.ui.sidebar').sidebar({
context: $('#main-sidebar-segment')
})
* {
border-radius: 0!important;
}
body {
background: #f1f1f1;
//background: #8b8b8b;
//display: flex;
//flex-flow: column;
height: 100%;
}
#main-sidebar-segment {
//display: flex;
//flex-flow: column;
}
.ui.main.container {
//flex: 1 1 auto;
}
.ui.inverted.footer.segment {
//flex: 0 1 40px;
margin: 0;
z-index: 1000;
}
.ui.grid {
//margin: 1rem;
}
.ui.inverted.green.dashboard.segment {
background-color: #2fb34e!important;
color: #FFF!important;
}
.ui.inverted.orange.dashboard.segment {
background-color: #f26b1c!important;
}
.ui.stat.header.segment {
padding: 0.5em;
}
.ui.inverted.dark.blue.segment {
border: 2px solid #2185D0;
background-color: #4c4f52!important;
}
.ui.ordered.large.list .list>.item:before,
.ui.ordered.large.list > .item::before {
font-size: 1.3em;
content: counters(ordered, " ") ". ";
}
.ui.ordered.large.list .content {
margin-left: 0.3em;
}
.ui.secondary.blue.filled.segment {
background: linear-gradient(rgba(255, 255, 255, .2) 0, rgba(255, 255, 255, .2) 100%) #4c4f52;
background-color: #2185D0!important;
}
.black.header {
color: black;
}
h3.compact.header {
margin: 0 !important;
}
.ui.inverted.sidebar {
background: #37393a;
//margin-top: 40px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.4/semantic.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.4/semantic.min.js"></script>
<body >
<div id="main-sidebar-segment" style="margin-bottom: 0; border: none;" class="ui bottom attached segment pushable">
<div class="ui left visible inline vertical inverted thin sidebar labeled menu">
<a class="item">
<i class="home icon"></i> Home
</a>
<a class="item">
<i class="bar chart icon"></i>Reports
</a>
<a class="item">
<i class="ordered list icon"></i>Leaderboards
</a>
<a class="item">
<i class="configure icon"></i>Tools
</a>
</div>
<div class="ui inverted fluid fixed menu">
<div class="ui container">
<a class="active item"><i class="home icon"></i>Home</a>
<div class="compact right menu">
<div class="ui dropdown item">
<div class="default text">Select World</div>
<input type="hidden" value="">
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="1">World 1</div>
<div class="item" data-value="2">World 2</div>
<div class="item" data-value="3">World 3</div>
</div>
</div>
<a class="icon item"><i class="options icon"></i></a>
<a class="item"><i class="orange sign out icon"></i>Logout</a>
</div>
</div>
</div>
<div class="pusher">
</div>
<div class="ui inverted footer segment">
<div class="ui center aligned container">
<div class="ui horizontal inverted small divided link list">
<a class="item" href="#">Report An Issue</a>
<a class="item" href="#">Chat</a>
<a class="item" href="#">Contact</a>
</div>
<div>
Created and maintained by
<a class="teal link" href="#">
<h5 style="display:inline;" class="ui teal header">
Douglas Gaskell
</h5>
</a>
</div>
</div>
</div>
</div>
</body>
The .pusher has a min-height: 100% which is the culprit pushing your footer out of the viewport.
I would just override that style (or if you are using the .pusher class elsewhere make a new css class for it.)
#main-sidebar-segment .pusher {
min-height: calc(100vh - 80px);
}
I do 80px because that is the height of your footer.
https://jsfiddle.net/8yobm8u3/

Why is bootstrap button so wide?

I've got a jumbotron class which has to contain a button, but it's strangely extended and that button looks ugly. Why is that so?
HTML
<div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-md-8">
<button class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-ok">
Why is this button so wide?
</span>
</button>
</div>
</div>
</div>
</div>
CSS
.jumbotron {
margin: 10px;
}
.row {
margin: 8px 0;
}
If I try to reduce the size of the column, for example, col-md-4, nothing changes.
Your mistake is you wrote the text inside icon span. Here is the fixed code
.jumbotron {
margin: 10px;
}
.row {
margin: 8px 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-md-8">
<button class="btn btn-primary btn-sm">
<span class="glyphicon glyphicon-ok"></span>
Why is this button so wide?
</button>
</div>
</div>
</div>
</div>
in main page use this...
<header>
<div class="container">
<div class="intro-text">
<div class="intro-lead-in">Welcome!!!</div>
<div class="intro-heading">Let's Get Started</div>
Tell Me More
</div>
</div>
</header>
in css
use this
.btn-xl {
padding: 20px 40px;
border-color: #fed136;
border-radius: 3px;
text-transform: uppercase;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 18px;
font-weight: 700;
color: #fff;
background-color: #fed136;
}
this will solve your problem

Working on page flow in responsiveness using css and images

I am working on the below reference image work on responsiveness using css media query and images. I am trying to avoid position I am not getting the excact output which I required.
Here is my Fiddle link
Here is my HTML Code
<div class="container-fluid">
<div class="row-fluid">
<div class="flw_width">
<label class="pull-left flw_text green_prog_text">Basic Information</label>
<div class="col-xs-4 col-sm-4 col-md-1">
<div class="flw_circle_green">
</div>
</div>
<div class="col-xs-4 col-sm-4 col-md-3">
<div class="green_prog">
</div>
</div>
<label class="pull-left flw_text cst_text">Education & Health</label>
<div class="col-xs-4 col-sm-4 col-md-1">
<div class="flw_circle_grey">
</div>
</div>
<div class="col-xs-4 col-sm-4 col-md-3">
<div class="grey_prog">
</div>
</div>
<label class="pull-left flw_text cst_text">Attach & Declaration</label>
<div class="col-xs-4 col-sm-4 col-md-1">
<div class="flw_circle_grey">
</div>
</div>
<div class="col-xs-4 col-sm-4 col-md-3">
<div class="grey_prog">
</div>
</div>
<label class="pull-left flw_text pay_text">Payment</label>
<div class="col-xs-4 col-sm-4 col-md-1">
<div class="flw_circle_grey">
</div>
</div>
</div>
</div>
</div>
My CSS Code
.flw_width{
width: 480px;
margin: 0px auto;
padding-top:45px;
padding-bottom: 60px;
}
.flw_text{
font-size: 13px;
color: #ced3d0;
font-family: 'Open Sans', sans-serif;
width: 0px;
white-space: nowrap;
margin-top: -35px;
margin-left: -45px;
border:0px;
}
.flw_text, .cst_text{
margin-left: -46px !important;
}
.pay_text{
padding-left:26px;
}
.flw_circle_grey{
background: url(../images/grey_Circle.jpg) no-repeat;
width: 20px;
height: 20px;
margin-left: -35px;
margin-top: -7px;
}
.flw_circle_green{
background: url(../images/green_Circle.jpg) no-repeat;
width: 20px;
height: 20px;
margin-top: -6px;
margin-left: 0px;
}
.grey_prog{
background-color: #ced3d0;
height: 6px;
margin-left: -24px;
border: 1px solid #bdbdbd;
}
.green_prog_text{
color: #84bd00;
}
.green_prog{
background-color: #84bd00;
height: 6px;
margin-left: -24px;
}
My current output was like this.
Here is the reference image. Kindly help me I was struggling like anything.
Please do the needful.
You have selected the column grid wrongly, I think For the class which are representing the font awesome circle (green dot) fa fa-circle flw_circle_green can be changed to single grid where you have defined a 4 column grid.
Try updating the four column grid to one column 1 column and use the

Resources