I have the following HTML
<h2 class="border-center-right mt-4">
<span class="bg-white float-left">CREDITCARDNAME</span>
<button type="button" class="btn btn-primary float-right">APPLY NOW</button>
</h2>
I'm using Bootstrap 4. The border is currently overlapping the "Apply Now" button. How can I make it so the border sits behind the button?
THANKS!
I added the code to the following Fiddle: https://jsfiddle.net/katzumi/98c5q2cf/
And these are the border styles currently applied to <h2 class="border-center-right mt-4">:
You should be able to just remove float-left from your span.
I made the border red so it was easier to see against a white background.
<div class="container mb-5">
<h2 class="border-center-right mt-4" style="border-bottom: 1px solid red;">
<span class="d-inline-block bg-white">CREDITCARDNAME</span>
<button type="button" class="d-inline-block btn btn-primary float-right">APPLY NOW</button>
</h2>
<div class="text-4-col">
</div>
</div>
https://jsfiddle.net/98c5q2cf/2/
Fixed! I reduced the width of the element &::after the border-center-right class.
#include media-breakpoint-up(sm) {
.border-center-right {
position: relative;
overflow: hidden;
&::after {
content: "";
display: inline-block;
height: 1px;
position: absolute;
top: 50%;
transform: translateY(-50%);
**width: 50%;**
background: $accent-secondary;
margin-left: 1rem;
}
}
}
Related
When I center my menu items using justify-content: center the left border of the left icon disappears. (View issue on JSFiddle)
My workaround is to manually assign a border using .add-left-border. However I'm not sure why this is required. Anybody know what's going on here?
#header-menu {
justify-content: center;
}
/* Why do I have to add this for border to show up? */
.add-left-border {
border-left: 1px solid rgba(34,36,38,.15);
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css"/>
<div class="ui icon menu" id="header-menu">
<a class="item add-left-border">
<i class="code branch icon "></i>
</a>
<a class="item">
<i class="github icon"></i>
</a>
<a class="item">
<i class="envelope icon"></i>
</a>
</div>
None of the buttons have a left border as they all apply borders to their right side (see below), while the first button depends on the menu's border to provide its visual boundary.
.ui.menu .item::before {
position: absolute;
content: '';
top: 0;
right: 0;
height: 100%;
width: 1px;
background: rgba(34,36,38,.1);
}
You will always need to use a bespoke solution as the framework doesn't appear to provide a centered menu. For purposes of consistency and cleaner HTML, you can achieve it with only CSS modifications:
#header-menu {
justify-content: center;
}
#header-menu .item:first-child::after {
position: absolute;
content: '';
top: 0;
left: 0;
height: 100%;
width: 1px;
background: rgba(34,36,38,.1);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css"/>
<div class="ui icon menu" id="header-menu">
<a class="item">
<i class="code branch icon"></i>
</a>
<a class="item">
<i class="github icon"></i>
</a>
<a class="item">
<i class="envelope icon"></i>
</a>
</div>
I'm using angularJS with bootstrap, and I'm creating a modal that will show some infos when you click on a button.
As there will be multiple button around the page, I want that this modal pops up near the clicked button, like the modal top-left corner being on top of the button I clicked.
Is this possible? I tried multiple things and the modal always pops up in the middle of the screen.
Current code I'm trying is:
.modal.in {
position: absolute;
bottom: 0;
right: 0;
left: auto;
top: auto;
bottom: 0;
overflow: auto;
}
.testbox {
background: #fff;
color: #000;
padding: 10px;
min-height: 200px;
min-width: 300px;
position: absolute;
}
and here the htm page that has the modal content:
<div class="testbox">
<div class="modal">
<div class="modal-header">
<h3 class="modal-title" ng-bind-html="title"></h3>
</div>
<div class="modal-body">
<span ng-bind-html="fullText"></span>
<div class="modal-footer">
<button class="btn btn-default" type="button" ng-click="close()"><i class="fa fa-close"></i></button>
</div>
</div>
</div>
</div>
I tried many things in the css but no one seems to be working, I could get something with position: fixed but of course only for one button.
Any ideas?
you might consider using bootstrap popover to do this.
here is an example
<button type="button" class="btn btn-danger popover-dismiss" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</button>
How to align vertically middle bootstrap alert dismiss button?
<div class="alert alert-dismissible alert-info" role="alert">
<div class="alert-message">
Multi<br>
Line<br>
Alert
</div>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
Fiddle: https://jsfiddle.net/b5asr9xj/4/
div alert-message is there just because I'm using jQuery.html to update content in it...
You could wrap your text in <p></p> tags and then set text-align: center; on them.
Updated fiddle
Does this solve your problem?
If you want to align it. Vertically in the middle you can do something like this with your current html.
.alert-message {
text-align: center;
button{
display: inline-block;
}
within your alert-message class you align the text to the center and you can then make it display inline(vertical).
see Updated fiddle
You can do like this for vertically middle.
Add parent div to position: relative;
See demo link here. https://jsfiddle.net/rhwxm3md/1/
<div class="alert alert-dismissible alert-info" role="alert">
<div class="alert-message">
Multi<br>
Line<br>
Alert
</div>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
CSS CODE:
.alert-info {
background-color: #d9edf7;
border-color: #bce8f1;
color: #31708f;
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
width: 100%;
text-align: center;
}
I'm using bootstrap's class
<div class="btn-group btn-group-justified">
Buttons are perfect the way they are (I need them equally spaced and taking full length) but I would like a little space between them. I tried playing around with margins, width percentage and padding with no success.
Please see this codepen http://codepen.io/crhistian/pen/WwyWYM?editors=0100
HTML
<div class="panel-footer">
<div class="row">
<div class="col-xs-2">
<div class="row custom-row">
<div class="col-md-6">
<button class="btn btn-info btn-block">Cart</button>
</div>
<div class="col-md-6">
<button class="btn btn-success btn-block">Checkout</button>
</div>
</div>
</div>
</div>
</div>
CSS
.custom-row {
margin-left: -5px;
margin-right: -5px;
}
.custom-row .col-md-6 {
padding-left: 5px;
padding-right: 5px;
}
For the first button in the div tag
.btn-group {
float: left;
width: 45%;
}
And for your other button (add "2" to the other buttons div tag class):
.btn-group2 {
float: right;
width: 45%;
}
Then you can add margins for the same classes if you want to position them better
Take a look at this http://jsfiddle.net/0ftrnkxo/
and the site http://omarhabash.com/sites
This looks great from a desktop.. I usually dont have problems with responsive design but what can I do to make this responsive?
THE HTML
<div id="g-site1" class="col-xs-12 demo-container">
<div class="same-s same-1">
<img class="img-responsive" src="http://omarhabash.com/sites/assets/img/sites/site1.jpg" alt="">
</div>
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#site1"> <i class="fa fa-search-plus"></i>
</button>
<div class="same-s same-2">
<img class="img-responsive" src="http://omarhabash.com/sites/assets/img/sites/mac.png" alt="">
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="site1" tabindex="-1" role="dialog" aria-labelledby="site1Label" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content1">
<div class="modal-body">
<img class="img-responsive site" src="http://omarhabash.com/sites/assets/img/sites/site1.jpg" alt="">
</div>
</div>
</div>
</div>
THE CSS
.same-s {
height: 160px;
width: 100%;
margin: 0 auto;
}
.same-s img {
width: 100%;
display: block;
margin: 0 auto;
height: auto;
}
.same-s.same-1 {
width: 66.5%;
overflow: scroll;
position: absolute;
margin-left: 174px;
margin-top: 65px;
height: 57.25%;
}
.demo-container {
height: 56em;
}
button.btn.btn-primary.btn-lg {
margin-left: 9.9em;
margin-top: 26.5em;
position: absolute;
}
img.site {
border: 4px solid #ccc;
}
With any grid system it's best to keep it and your content separate. Don't "hack the core", as the saying goes. Here's a simplified start:
http://jsfiddle.net/isherwood/0ftrnkxo/3
.demo-container {
overflow: hidden; /* demo only--accounts for image whitespace */
}
.mac {
position: relative;
margin: -5.3% -20.5% 0 -18.5%; /* demo only--accounts for image whitespace */
}
.screen {
position: absolute;
top: 9%; /* demo only--accounts for image whitespace */
right: 17%; /* demo only--accounts for image whitespace */
left: 15.6%; /* demo only--accounts for image whitespace */
height: 58%;
overflow: auto;
}
<div class="row">
<div class="col-xs-12">
<div class="demo-container">
<div class="mac">
<img class="img-responsive" src="http://omarhabash.com/sites/assets/img/sites/mac.png" alt="" />
<div class="screen">
<img class="img-responsive" src="http://omarhabash.com/sites/assets/img/sites/site1.jpg" alt="" />
</div>
</div>
</div>
</div>
</div>
To eliminate all those negative margins and the corresponding values on .screen, crop your Mac image tight to the black border. Of course, you'll still need smaller top, right, and left values to allow the Mac's frame to show around it.
I'd also fill the Mac image's screen entirely with black. That will eliminate the need to so perfectly position what's overlaying it.
Here's a demo with two Macs in two rows.