This is the html I'm working with (which I cannot change):
<div class="article-summary media">
<div class="media-body">
<h3 class="media-heading">
<a href="">
Boosting SRL for Recommendation Systems
</a>
</h3>
<div class="meta">
<div class="authors">
Kaushik Roy
</div>
</div>
<div class="btn-group" role="group">
<a class="galley-link btn btn-default role=" button"="" file"="" href="">
PDF
</a>
<a class="galley-link btn btn-default role=" button"="" file"="" href="">
XML
</a>
</div>
</div>
<div class="media-body">
....
</div>
</div>
This is what it looks like now
This is how I want it to look
I'm trying to push the PDF|XML btn-group to the upper right. If the h3.media-heading is long, it should stop short of the btn-group and continue on the next line instead of pushing the btn-group down
Here's my current solution but I'm not sure if there are any side-effects I'm not thinking of
.media-body {
position: relative;
}
.media-heading {
float: left;
padding-right: 150px;
}
.meta {
float: left;
clear: left;
}
.media-body > div.btn-group {
position: absolute;
right: 0;
}
Basically, I float all the .media-heading and .meta to the left, and I try to use absolute position to place the btn-group. I add a relative position to the btn-group's container, which is the .media-body because I learned that helps contain the absolute positioning of the element, otherwise, it flies out of the container and to the right of the entire page.
Related
I have a link button that I need to place to the right of a div. Adding float-left on the div and float-right on the link button does not do it. What am I doing wrong?
https://jsfiddle.net/3v2s4c50/
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="card-header">Today and Tomorrow</div>
<div class="card-body">
<div class="float-left">Someone somewhere is waiting for you.</div>
<a role="button" href="google.com" class="float-right btn btn-primary"> Login</a>
</div>
</div>
</div>
<div class="col">
2 of 2
</div>
</div>
</div>
remove floats and add:
.card-body{
display: flex;
justify-content: space-between;
align-items: center;
}
<div class="card-body d-flex">
<div class="flex-fill">Someone somewhere is waiting for you</div>
<a role="button" href="google.com" class="flex-fill btn btn-primary"> Login</a>
</div>
Well, it is doing it. But the portion of the screen that is showing the results is not wide enough to show both the div with the text and the button in the same row.. then it breaks down.
If you change the text to something smaller, like 'Someone is waiting' you can see the button floating right :)
You can also set a fixed width for your text div (currently it is expanding based on the content).
<div class="card-body">
<div class="float-left" style="width: 50%;">Someone somewhere is waiting for you</div>
<a role="button" href="google.com" class="float-right btn btn-primary"> Login</a>
</div>
You can add your link to a div with any class. Then add style "text-align: right;" into your div like this:
.my-link {
text-align: right;
}
.
<div class="my-link">
<a role="button" href="google.com" class="float-right btn btn-primary"> Login</a>
</div>
.
I hope this will be useful.
Trying to build a new site using Bootstrap-4
I'm trying to align a logo to the left, a link button in the center and a link button to the right of a footer div. At the moment, I've got it working except the logo is vertically aligned so that its top is middled rather than the center of the image, so its hanging low!
I've tried vertical aligning it and experimented with justify contents settings.
.footer {
background-color: #68B3E2;
text-align: center;
padding: 30px;
justify-content: space-around;
}
.logo {
display:inline-block;
float:left;
}
.center_btn {
display:inline-block;
float:none;
}
.right_btn {
display:inline-block;
float:right;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="footer">
<img class=logo src="images/logo.png" width="120" height="120" alt="">
<a class="center_btn btn-primary btn-lg" href="#" role="button">Ask a question</a>
<a class="right_btn btn-primary btn-lg" href="#" role="button">Register</a>
</div>
This is simpler using the Bootstrap flexbox util classes (no need for all the extra CSS)...
<div class="footer d-flex justify-content-between align-items-center">
<img class=logo src="//placehold.it/120" width="120" height="120" alt="">
<a class="center_btn btn-primary btn-lg" href="#" role="button">Ask a question</a>
<a class="right_btn btn-primary btn-lg" href="#" role="button">Register</a>
</div>
https://codeply.com/p/QpjEZtn11G
Good day! Just use Flexbox CSS, keep it simple.
.footer {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
background-color: #68B3E2;
padding: 30px;
}
<div class="footer">
<img class=logo src="https://avatars.mds.yandex.net/get-pdb/2978990/ac5c48be-c30e-4595-9f4b-72fa8d31addb/s375" width="120" height="120" alt="">
<a class="center_btn btn-primary btn-lg" href="#" role="button">Ask a question</a>
<a class="right_btn btn-primary btn-lg" href="#" role="button">Register</a>
</div>
The image and buttons are inside a div. How can i make the image occupy the whole div with buttons on the top right corner on the image?
This is the div that contains two buttons and an image. How can i place the two buttons on the top right corner of the image?
I tried to do position:relative;top:25px but the button will behind the image
<div class="image">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
<img src="{{ $image->image }}" class="img img-responsive full-width">
</div>
Use relative and absolute like shown below to achieve the desired effect.
P.S: I have used T and P to denote the icons as they were not visible in the snippet.
.image {
position: relative;
display: inline-block;
}
.overlay {
position: absolute;
right: 0;
z-index: 5;
}
<div class="image">
<div class="overlay">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
T<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
P<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
</div>
<img src="https://picsum.photos/200" class="img img-responsive full-width">
</div>
Please try this code. Use Position relative and absolute like this:
.image {
position: relative;
}
.image .delete-image-btn,
.image .edit-image-btn {
position: absolute;
top: 0;
right: 0;
z-index: 1;
}
.image .edit-image-btn {
margin-right: 40px;
}
Though there are many ways, a simple solution would be to give the buttons a z-index property.
.delete-image {
z-index :1;
}
.image {
position: relative;
}
.image .actions {
right: 1em;
top: 1em;
display: block;
position: absolute;
}
.image .actions a {
display: inline-block;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="image">
<div class="actions">
<a href="{{ url('/image/'.$image->id.'/delete') }}">
<button type="button" class="btn btn-default delete-image-btn pull-right">
<span class="glyphicon glyphicon-trash"></span>
</button>
</a>
<a href="{{ url('/image/'.$image->id.'/edit') }}">
<button type="button" class="btn btn-default edit-image-btn pull-right">
<span class="glyphicon glyphicon-pencil"></span>
</button>
</a>
</div>
<img src="https://cdn.pixabay.com/photo/2013/07/12/17/47/test-pattern-152459_960_720.png" class="img img-responsive full-width">
</div>
I have a bootstrap navbar. I have 3 pictures. I want one to pull right, one to pull left, and one to be in the center. I got the right and left, can't figure out how to center the last image. Tried CSS and wrapping it in a <p>, but it makes a separate line from the rest of the images.
Is there some CSS/bootstrap/html trick I'm not aware of?
<div class="nav navbar-inverse navbar-fixed-bottom">
<div class="container">
<img class="contactPicture pull-center" src="img/gmailIcon.png">
<img class="contactPicture pull-left" src="img/githubIcon.png">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
</div>
</div>
Asumming that the images are in relative positioning. You should just re-order your html?
So instead of:
<img class="contactPicture pull-center" src="img/gmailIcon.png">
<img class="contactPicture pull-left" src="img/githubIcon.png">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
You want:
<img class="contactPicture pull-left" src="img/githubIcon.png">
<img class="contactPicture pull-center" src="img/gmailIcon.png">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
if all else fails you can wrap it in a which may or may not work depending on your css.
I don't think there is any built it way to do this so you'll (most likely) have to position it yourself. Here's an example.
See Snippet.
.footer-img-center {
left: 50%;
position: absolute;
margin-left: -25px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="nav navbar-inverse navbar-fixed-bottom">
<div class="container">
<img class="contactPicture pull-left" src="http://placehold.it/50x50/f00">
<img class="contactPicture footer-img-center" src="http://placehold.it/50x50/fff">
<img class="contactPicture pull-right" src="http://placehold.it/50x50/ff0">
</div>
</div>
Since there's no "pull-center" in bootstrap, you can keep your markup the same and add the following to the CSS:
.nav .container {text-align:center;}
http://www.bootply.com/hsZ9HaJJmO
Okay folks, figure this one out. Put the image, in a row, in a col. Put the trouble image as a brand. here's my html
<div class="nav navbar-inverse navbar-fixed-bottom">
<div class="container">
<div class="row">
<div class="col-md-4">
<img class="contactPicture pull-left" src="img/githubIcon.png">
</div>
<div class="col-md-4">
<a class="navbar-brand-gmail" href="#"><img class="contactPicture gmail" src="img/gmailIcon.png"></a>
</div>
<div class="col-md-4">
<img class="contactPicture pull-right" src="img/linkedinIcon.png">
</div>
</div>
</div>
</div>
here's my custom css, taken from here http://www.bootply.com/9SOuY3vHlF
.navbar-brand-gmail {
position: absolute;
width: 100%;
left: 0;
text-align: center;
padding-top: 0;
margin: auto;}
the only thing I changed was adding padding top to zero, so it's in line with the other images.
I'd really appreciate some help on an issue i'm having.
For reference: http://trs-studios.com/test
I'm trying to get the 3 boxes (side to side) to align to the center of the page.
<div class="wrapper">
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank"></i> MEDIA</a>
<div class="spacer"/>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank"></i> STUDIO</a>
<div class="spacer"/>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank"></i> DESIGN</a>
</div>
Css for wrapper
.wrapper {
padding-top: 100px;
text-align: center;
}
Css for spacer
.spacer {
display: inline;
margin: 50px 50px;
position: relative;
text-align: center;
}
I'd appreciate any help!
Forget those spacing divs, HTML is not for styling.
Using display: inline-block on your links, you can simply put margin on them.
HTML:
<div class="wrapper">
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank">MEDIA</a>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank">STUDIO</a>
<a class="btn btn-large" href="URL TO YOUR SUBSITE" target="_blank">DESIGN</a>
</div>
CSS:
.wrapper {
text-align: center;
}
.wrapper .btn {
display: inline-block;
margin: 50px 25px;
}
Working demo