How to style an alert with two call to actions - html

I am attempting to create an alert using html and css to look like this example below
I've been able to create this using inline CSS and it is not the desired look I was hoping for.
What is the best away to adjust my current code in order to achieve the look of the example? At the moment I using two separate divs and adjusting the margins.
<div class="row" id="alert_box">
<div class="col m2">
<div class="card red darken-1">
<div class="row">
<div class="col ">
<div class="card-content white-text">
<p style="margin-bottom: 40px">What information do you want to see? We'd love to hear from you</p>
</div>
</div>
</div>
</div>
</div>
<div class="col m1" style="
margin-left: -23px">
<div class="card red darken-1">
<div class="row">
<div>
<div class="card-content white-text">
<p>button 1</p>
</div>
<div class="card-content white-text">
<p>button 2</p>
</div>
</div>
</div>
</div>
</div>
</div>

If you are not using bootstrap, then flex or grid can help you here :
flex possible example, both columns will be stretching to match the highest:
.row {
display: flex;
}
.alert,
.alert button {
background: rgb(200, 35, 51);
color: beige
}
.col,
.flex-1 {
flex: 1
}
.flex-3 {
flex: 3;
}
.flex-column {
display: flex;
flex-direction: column;
}
.m-auto {
margin: auto;
}
.m1 {
margin: 1em;
}
div,
button {
border: solid 1px #222;
}
<div class="row alert m1">
<div class="colt flex-3 flex-column ">
<p class="m-auto">some text standing here</p>
<p class="m-auto">some text standing here</p>
<p class="m-auto">some text standing here</p>
<p class="m-auto">some text standing here</p>
</div>
<div class="col flex-column">
<button class="flex-1">button 1</button>
<button class="flex-1">button 2</button>
</div>
</div>
<div class="row alert m1">
<div class="colt flex-3 flex-column ">
<p class="m-auto">some text standing here</p>
</div>
<div class="col flex-column">
<button class="flex-1">button 1</button>
<button class="flex-1">button 2</button>
<button class="flex-1">button 3</button>
</div>
</div>

You can do something like this:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row bg-secondary text-light" id="alert_box" style="max-width:516px;">
<div class="col-9" style="padding: 13px 6px 11px 33px;border-right: 1px solid #fff;">
What information do you want to see? We'd love to hear from you
</div>
<div class="col-3">
<div class="row">
<div class="col-12"style="border-bottom: 1px solid #fff;">
<button class="btn pull-right text-light">Button 1</button>
</div>
<div class="col-12">
<button class="btn pull-right text-light">Button 2</button>
</div>
</div>
</div>
Check this live example

Related

Can't get to boxes to align next to each other when there is a button with a link

I want to align two boxes horizontal to each other, but when i add a button with a link. The are align vertical.
.box-element{
box-shadow:hsl(0, 0%, 80%) 0 0 16px;
background-color: #fff;
border-radius: 4px;
padding: 10px;
}
<div class="col-lg-6">
<div class="box-element">
<hr>
<h3>Order Summary</h3>
<hr>
<div class="cart-row">
<div style="flex:2"><img class="row-image" src="{% static 'images/placeholder.png' %}"></div>
<div style="flex:2"><p>Product 1</p></div>
<div style="flex:1"><p>$20.00</p></div>
<div style="flex:1"><p>x2</p></div>
</div>
<h5>Items: 2</h5>
<h5>Total: $4</h5>
</div>
</div>
result:
: https://i.stack.imgur.com/cs67Y.png
<div class="col-lg-6">
<div class="box-element">
<a href="{% url 'cart' %}" class="btn btn-outline-dark" >← Back to Cart</a>
<hr>
<h3>Order Summary</h3>
<hr>
<div class="cart-row">
<div style="flex:2"><img class="row-image" src="{% static 'images/placeholder.png' %}"></div>
<div style="flex:2"><p>Product 1</p></div>
<div style="flex:1"><p>$20.00</p></div>
<div style="flex:1"><p>x2</p></div>
</div>
<h5>Items: 2</h5>
<h5>Total: $4</h5>
</div>
</div>
enter image description here
thank you in advanced:)
From what I could gather by the code you provided, I believe adding the code below ought to fix the layout to where the two boxes are aligned horizontally even with the button.
.col-lg-6 {
display: inline-block;
}

Bootstrapping buttons

I am trying to make three parallel square shape buttons with title in center. something like this
My title
Square button-1 square button-2 square button-3
My code is as follows::
<div class="col-md-12 pt-md-5 text-center">
<p>My title</p>
</div>
<div class="container">
<div class="row">
<div class="col-xs-4">
<div>
<button class="btn btn-sq-lg btn-info">button-1</button>
</div>
<div >
<button class="btn btn-sq-lg btn-info">button-2</button>
</div>
<div>
<button class="btn btn-sq-lg btn-info">button3</button>
</div>
</div>
</div>
</div>
.btn-sq-lg {
width: 150px !important;
height: 150px !important;
}
output I am getting is three vertical without any spaces. But I want three parallel square buttons with equal spaces
how can I do that?
Also how can I make button with white color and black text and title with white color and increase font size?
Just made button as info but want a white background with black text
col-xs-** has been replaced with col-** in v4. You need to separate each button with col-4
.btn-sq-lg {
width: 150px !important;
height: 150px !important;
background: #ffff!important;
color: black!important
}
.square {
text-align: center
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<p class="p-5 w-100 text-center">My title</p>
<div class="container">
<div class="row">
<div class="col-4">
<div class="square">
<button class="btn btn-sq-lg btn-info ">button-1</button>
</div>
</div>
<div class="col-4">
<div class="square">
<button class="btn btn-sq-lg btn-info">button-2</button>
</div>
</div>
<div class="col-4">
<div class="square">
<button class="btn btn-sq-lg btn-info">button3</button>
</div>
</div>
</div>
</div>
Use justify-content-between to row and remove the div with col-xs-4 (xs does not exist in bootstrap 4)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="col-md-12 pt-md-5 text-center">
<p>My title</p>
</div>
<div class="container">
<div class="row justify-content-between">
<div>
<button class="btn btn-sq-lg btn-info">button-1</button>
</div>
<div>
<button class="btn btn-sq-lg btn-info">button-2</button>
</div>
<div>
<button class="btn btn-sq-lg btn-info">button3</button>
</div>
</div>
</div>

Bootstrap 4: Full Width Inline Button

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>

rows in Bootstrap grid don't line up

Just trying to make a second row of col-md-6s (I copied the "row" div and pasted it within the container div) but I can't seem to figure out why its not perfectly lined up.
The last two lines of HTML code reflect the beginning of the second row.
.btn-group-vertical{
border: 2px solid black;
border-radius: 10px;
}
.col-md-6 {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
#prod_view {
height: 100%;
background-color: lightcoral;
display: flex;
justify-content: flex-start;
border: solid;
border-radius: 10px;
}
.col-md-6 > div:last-child {
width: 50%;
}
.boxclass {
height: 95%;
width: 50%;
}
<div class="container">
<div class="row">
<div class="col-md-6" style="background-color: lightcyan">
<div class="btn-group-vertical btn-group-lg">
<button type="button" class="btn btn-primary">Quick Select</button>
<button type="button" class="btn btn-primary">Show in Depth</button>
<button type="button" class="btn btn-primary">Delete Product</button>
</div>
<div>
<div id="prod_view">
<div class="boxclass" >
<img alt="product" class="img-rounded" src="../Images/math.jpg" style="max-height: 100%; max-width: 100%;">
</div>
<div class="boxclass">some cool blocks all stacked up n shtufff</div>
</div>
</div>
</div>
<div class="col-md-6" style="background-color: lightgray">
<div class="btn-group-vertical btn-group-lg">
<button type="button" class="btn btn-primary">Quick Select</button>
<button type="button" class="btn btn-primary">Show in Depth</button>
<button type="button" class="btn btn-primary">Delete Product</button>
</div>
<div>
<div id="prod_view">
<div class="boxclass"></div>
<div class="boxclass"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6" style="background-color: lightcyan">
Works fine when the .row is closed properly...
http://www.codeply.com/go/OCsEsFb2Lr
<div class="container">
<div class="row">
<div class="col-md-6" style="background-color: lightcyan">
</div>
<div class="col-md-6" style="background-color: lightgray">
</div>
</div>
<div class="row">
<div class="col-md-6" style="background-color: lightcyan">
</div>
<div class="col-md-6" style="background-color: lightgray">
</div>
</div>
</div>

Horizontal align center with offset in Bootstrap 3

I have a bootstrap 3 based layout, with two columns, how can I make sure the text in the second aligns with the center (horizontal) of the page?
HTML:
<div class="row spaced">
<div class="col-sm-2 text-center">
<img src="Images/picture.png" alt="Image" height="100%" width="100%">
</div>
<div class="col-sm-10 text-center horizontal-center">
<h1 class="text-box text-center horizontal-center">Are you interested?</h1>
<button type="button" class="btn btn-primary btn-lg outline text-center">Find Out More</button>
</div>
</div>
CSS:
.horizontal-center {
display: inline-block;
vertical-align: middle;
text-align: center;
float: none;
}
JSFiddle
You can pull the image left and take it out of the container, then make the div 12 so it will use the whole screen
<div class="col-sm-2 pull-left">
<img src="Images/picture.png" alt="space taking image to push other columns off center" height="100%" width="100%">
</div>
<div class="container">
<div class="row spaced">
<div class="col-sm-12 text-center horizontal-center">
<h1 class="text-box text-center horizontal-center">Are you interested to find out more? Then click the button below.</h1>
<button type="button" class="btn btn-primary btn-lg outline text-center">Find Out More</button>
</div>
</div>
</div>
https://jsfiddle.net/ygznu3gy/