I have a this container (React):
<div className='container mt-3 border border-white'>
{[...Array(3).keys()].map((row) => (
<div key={row} className='row'>
{[...Array(3).keys()].map((col) => (
<div key={col} className='border border-dark col'>
<p>{row * 3 + col + 1}</p>
</div>
))}
</div>
))}
</div>
I have this grid container and I'd like to remove the border from the outer part, I tried border-0 but it doesn't work and with border border-white the line is still visible
for clarity:
I'm afraid you can't do it easily using bootstrap classes.
Inspired from this answer, you could do :
.container .col {
border: 1px solid black;
}
.container .row:first-child .col {
border-top: none;
}
.container .row:last-child .col {
border-bottom: none;
}
.container .row .col:first-child {
border-left: none;
}
.container .row .col:last-child {
border-right: none;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class='container mt-3'>
<div class="row">
<div class="col">
<p>col</p>
</div>
<div class="col">
<p>col</p>
</div>
<div class="col">
<p>col</p>
</div>
</div>
<div class="row">
<div class="col">
<p>col</p>
</div>
<div class="col">
<p>col</p>
</div>
<div class="col">
<p>col</p>
</div>
</div>
</div>
try to use
border: none !important;
box-shadow: none !important;
sometimes you have to use the !important tag when using bootstrap and other libraries
Related
I wanted to implement the design below , but I am having trouble on the positions , can anyone give a basic css example and implementation of the sample image below ? Help would really be appreciated. Thank you. are we going to use col for that ? how do we seperate text based on the design ?
Really simple example using bootstrap:
.col {
background-color: red;
}
#icon {
background-color: green;
}
hr {
border-top-width: 3px !important;
}
.arrow-up {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid black;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<div class="row">
<div class="col m-2">
<div class="row">
<div id="icon" class="col-4">
ICON
</div>
<div class="col-8">
<h3>
Unmuted
<span class="arrow-up"></span>
</h3>
<hr>
<p>
Panacast
</p>
</div>
</div>
</div>
<div class="col m-2">
<div class="row">
<div id="icon" class="col-4">
ICON
</div>
<div class="col-8">
<h3>
Unmuted
<span class="arrow-up"></span>
</h3>
<hr>
<p>
Panacast
</p>
</div>
</div>
</div>
</div>
I have been trying to build a table with Bootstrap 4 grid container. Everything looks great (styling, alignment,...) except for one problem: the table doesn't follow the grid container as expected. It seems like only the first column expands/shrinks when I try to resize my browser.
I used the display property to build my table to solve alignment problems, but once I try putting col-# as class names for the columns, it doesn't seem to work.
.my-table {
border: 1px solid grey;
display: table;
padding: 0;
}
.my-table-row-header {
display: table-header-group;
height: 50px;
}
.first-header-column {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.my-table-body {
display: table-row-group;
}
.my-table-row {
height: 50px;
border-left: 1px solid grey;
border-bottom: 1px solid grey;
display: table-row;
}
.row-cell {
display: table-cell;
vertical-align: middle;
border-right: 1px solid grey;
}
.c-column {
display: table-cell;
vertical-align: middle;
text-align: center;
padding-left: 11px;
padding-right: 11px;
}
<div class="container-fluid no-gutters">
<div class="my-table col-9 table">
<div class="my-table-row-header row">
<div class="first-header-column col-1 row-cell">
<span class="c-column">c</span>
</div>
<div class="second-column col-4 row-cell">
<span>text</span>
</div>
<div class="third-column col-4 row-cell">
<span>text</span>
</div>
</div>
<div class="my-table-body">
<div class="my-table-row row">
<div class="first-column col-1 row-cell">
<span class="c-column">c</span>
</div>
<div class="second-column col-4 row-cell">
<span>text</span>
</div>
<div class="third-column col-4 row-cell">
<span>text</span>
</div>
</div>
<div class="my-table-row row">
<div class="first-column col-1 row-cell">
<span class="c-column">c</span>
</div>
<div class="second-column col-4 row-cell">
<span>text</span>
</div>
<div class="third-column col-4 row-cell">
<span>text</span>
</div>
</div>
</div>
</div>
</div>
Jsfiddle: https://jsfiddle.net/4zn5oby6/2/
If you try resizing your browser, you'll see the first column resizes accordingly. I expect it to follow the grid container size strictly.
P.S. Since my table contains other components (not just text), I would like to keep the display properties to assure my styling is on point if possible. Thanks.
I am not clear on what the question is exactly, but I noticed the col-9 needed to be in its own div. Then to equal 12 columns add the col-3 div after.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
.my-table {
border: 1px solid grey;
display: table;
padding: 0;
}
.my-table-row-header {
display: table-header-group;
height: 50px;
}
.first-header-column {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.my-table-body {
display: table-row-group;
}
.my-table-row {
height: 50px;
border-left: 1px solid grey;
border-bottom: 1px solid grey;
display: table-row;
}
.row-cell {
display: table-cell;
vertical-align: middle;
border-right: 1px solid grey;
}
.c-column {
display: table-cell;
vertical-align: middle;
text-align: center;
padding-left: 11px;
padding-right: 11px;
}
</style>
</head>
<body>
<div class="container-fluid no-gutters">
<div class="col-9">
<div class="my-table table">
<div class="my-table-row-header row">
<div class="first-header-column col-1 row-cell">
<span class="c-column">c</span>
</div>
<div class="second-column col-4 row-cell">
<span>text</span>
</div>
<div class="third-column col-4 row-cell">
<span>text</span>
</div>
</div>
<div class="my-table-body">
<div class="my-table-row row">
<div class="first-column col-1 row-cell">
<span class="c-column">c</span>
</div>
<div class="second-column col-4 row-cell">
<span>text</span>
</div>
<div class="third-column col-4 row-cell">
<span>text</span>
</div>
</div>
<div class="my-table-row row">
<div class="first-column col-1 row-cell">
<span class="c-column">c</span>
</div>
<div class="second-column col-4 row-cell">
<span>text</span>
</div>
<div class="third-column col-4 row-cell">
<span>text</span>
</div>
</div>
</div>
</div></div>
<div class="col-3"></div>
</div>
</body>
</html>
So, I found a way around it. Instead of using display: table-cell and all that vertical-align and text-align crap, I used display: flex which respected the bootstrap grid column width (which I'm still not sure why?).
I'm trying to get this result with boostrap :
The idea would be that : the black square stay as a square, even with the right "rows" being resized (on mobile for example)
And the red rows would be having the same height/width (I failed that on the image, just a quick paint mockup)
I'd love to show you some code that would be a starting point but after a few hours I'm unable to achieve this effect...
I found that template that use this kind of structure :
Gridus
Using flexbox as a wrapper.
* {
box-sizing: border-box;
}
.flexbox {
display: flex;
justify-content: left;
align-items: flex-start;
}
.col-md-10 {
border: thin solid darkgray;
max-height: 50px;
overflow: hidden;
height: 50px;
width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row nopadding flexbox">
<a href="#">
<div class="col-md-4 vc-photo photo-01"><img src="http://placehold.it/150" /></div>
</a>
<div class="col-md-8 nopadding">
<div class="row nopadding">
<div class="col-md-10">
<p>Bla</p>
</div>
</div>
<div class="row nopadding">
<div class="col-md-10">
<p>Bla</p>
</div>
</div>
<div class="row nopadding">
<div class="col-md-10">
<p>Bla</p>
</div>
</div>
</div>
</div>
You mean something like this? I didn't bother with the borders, but I can put it if you like
.left-div {
background-color: pink;
height: 120px;
width: 120px;
float:left;
}
.right-div {
background-color: red;
height: 120px;
float:left;
}
.col-xs-12{
height: 40px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="left-div">Column 1</div>
<div class="right-div">
<div class="row">
<div class="col-xs-12">Row 1</div>
<div class="col-xs-12">Row 2</div>
<div class="col-xs-12">Row 3</div>
</div>
</div>
</div>
</div>
The title might be misleading, but I didn't know how else to name it.
In any case, I need to have an div/image inlined with a text, and a button beneath that text. The issue is, I can't really make the button take the full width without adding any padding, no matter what I try.
To make my explanation clearer, here's an image of what I'm trying to make:
And I'm trying to use Bootstrap 4 utilities only.
This is my code so far:
.col-md-3 {
background-color: #ededed;
}
.img {
width: 188px;
height: 88px;
background-color: #292a2c;
}
.btn {
background-color: #292a2c;
color: #ededed;
}
<div class="col-md-3 d-flex p-0">
<div class="img"></div>
<div>
<h6 class="m-auto">Text goes here</h6>
<button class="btn rounded-0 btn-block">Button</button>
</div>
</div>
How can I make this work? Also, the div with a class .img is a placeholder in a way, and needs to stay like that.
Thank you!
You can achieve this by using bootstrap media object with no additional css. Please see code snippet below
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="media">
<img src="https://via.placeholder.com/188x88" class="mr-3" alt="">
<div class="media-body">
<h5 class="mt-0">Media heading</h5>
<button class="btn btn-primary btn-block">Button</button>
</div>
</div>
</div>
</div>
</div>
You can try something like this, then style it accordingly:
<div class="container-fluid">
<div class="row">
<div class="col-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ79Qe630Fli9-SIDz188GQURmrRfhh6AksMKexPP5JvsE7AJ6t01mf5A">
</div>
<div class="col-8">
<div class="row">
<p>text</p>
</div>
<div class="row">
<button>button</button>
</div>
</div>
</div>
</div>
Here is the code for getting as shown in the image
'<div class="col-md-12"><div class="row"><div class="col-md-3"><div class="row"><div class="img"></div></div></div>
<div class="col-md-6"><div class="row">
<h6 class="m-auto">Text goes here</h6><button class="btn rounded-0 btn-block">Button</button></div></div></div>
For style use the style in your question
You could do something like this.
Note that Bootstrap by default does not have a black background class so you would have to create one.
.bg-black {
background-color: #000 !important;
border: 2px solid #000 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid"> <!-- Make it full width -->
<div class="row d-flex"> <!-- display flex -->
<div class="col-4 align-self-stretch"> <!-- stretch the column -->
<img class="w-100" src="http://placehold.it/200x200" />
</div>
<div class="col-8 align-self-stretch"> <!-- stretch the column -->
<p>Some Text Here.<br/> Can be long or short</p>
<p>Yet another paragraph</p>
<p>And one more paragraph</p>
<button class="btn btn-primary bg-black btn-block rounded-0">Btn Txt</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
.col-md-3 {
background-color: #ededed;
width:100% !important;
}
.col-md-3> div{
display:inline-block;
float:left;
width: 60%;
height:100%;
}
.img {
width: 15% !important;;
height: 88px !important;
background-color: #292a2c;
display:inline-block;
}
.btn {
width: 60%;
background-color: #292a2c;
color: #ededed;
height:50%;
display:inline-block;
}
<div class="col-md-3 d-flex p-0">
<div class="img"></div>
<div>
<h6 class="m-auto">Text goes here</h6>
<button class="btn rounded-0 btn-block">Button</button>
</div>
</div>
Everything looks good just make sure that you have bootstrap.css file in right place and make sure that its working.
I made some changes to your code, its a bit hard coded but u must take care to overwrite bootstrap classes and don't change them directly.
.box {
background-color: #ededed;
}
.img {
width: 188px;
height: 88px;
background-color: #292a2c;
float: left;
margin-right: 5px;
}
.text {
float: left;
}
.btn {
background-color: #292a2c;
color: #ededed;
margin-top: 33px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-6 d-flex p-0">
<div class="box">
<div class="img"></div>
<div class="text">
<h6 class="m-auto">Text goes here</h6>
<button class="btn rounded-0 btn-block">Button</button>
</div>
</div>
</div>
I am trying to achieve this:
I want the three panels in the gray <div> to overlap with the white jumbotron above them. How can I do this in CSS or with Bootstrap?
HTML:
<div id="home-page">
<div class="container text-center">
<div class="row">
<div class="col-sm-4">
<div class="panel">
</div>
</div>
<div class="col-sm-4">
<div class="panel">
</div>
</div>
<div class="col-sm-4">
<div class="panel">
</div>
</div>
</div>
</div>
<div class="container">
<h3>Passionate About Technology?</h3>
<p>We make and effort to learn something everyday</p>
LEARN
</div>
</div>
CSS
#home-page { background: #EFEFEF; }
#home-page .panel { box-shadow: 0px 0px 10px gray; margin: 15px; }
Thanks!
I was able to replicate the pic you had with a few adjustments to your code:
here is the css:
#home-page {
background: #EFEFEF;
}
#home-page .panel {
box-shadow: 0px 0px 10px gray;
margin: 15px;
margin-top:-50px;
height:200px;
}
#jumbo{
height:100px;
}
I also added a div on top to get that effect
<div id="jumbo"></div>
please see my codepen
http://codepen.io/sammyb123/pen/dMJaRw
View below snippet in Full page. If you want the same effect on smaller devices then use col-xs instead.
#home-page .panel {
box-shadow: 0px 0px 10px gray;
height: 250px;
margin-top: -15px;
}
#home-page .jumbo-ctr {
background: #fff;
margin-bottom: 20px;
}
#home-page .panel-ctr {
background: #EFEFEF;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div id="home-page">
<div class="container jumbo-ctr">
<h3>Passionate About Technology?</h3>
<p>We make and effort to learn something everyday</p>
LEARN
</div>
<div class="container-fluid text-center panel-ctr">
<div class="row">
<div class=" col-sm-offset-3 col-sm-2 ">
<div class="panel">
</div>
</div>
<div class="col-sm-2 ">
<div class="panel">
</div>
</div>
<div class="col-sm-2 ">
<div class="panel"></div>
</div>
</div>
</div>
</div>