This question already has answers here:
Vertically align text next to an image?
(26 answers)
Closed 4 years ago.
I have added an image and text. Text has 1 <h6> and 2 <p> tags. I tried using float:left but it does not get displayed side by side.
content.js:
<div className="col l4">
<div className="card1">
<img className="javacardimg" src={java} alt="Java" height="65" width="65"></img>
<h6 className="cardtitle1">New Launch</h6>
<p className="cardcontent1">JAVA</p><p></p>
<p className="cardcontent1">Foundations</p>
</div>
</div>
<div className="col l4">
<div className="card2">
<img className="neuralcard" src={neural} alt="Neural Network" height="65" width="65"></img>
<h6 className="cardtitle2">Enroll Now</h6>
<p className="cardcontent2">Neural Newtwork</p><p></p>
<p className="cardcontent2">Foundations</p>
</div>
</div>
css:
.cardcontent{
float: left;
}
.card1 {
width: 100%;
}
.card1 > h6 {
margin: 0px;
}
I want to display New Launch JAVA Foundations on right of image similarly for card2 but current css does not work I tried few css styling but does not work.
Screenshot:
Try to use Flexbox here...and also wrap your right side content into a div for better practice and readability
.card1 {
display: flex;
align-items: flex-start;
}
h6 {
margin-top: 0;
}
.item {
padding-left: 10px;
}
<div class="card1">
<img className="javacardimg" src="http://via.placeholder.com/100x100?text=JAVA" alt="Java">
<div class="item">
<h6 className="cardtitle1">New Launch</h6>
<p className="cardcontent1">JAVA Foundations</p>
</div>
</div>
Related
This question already has answers here:
How can I vertically align elements in a div?
(28 answers)
Closed 10 months ago.
I have three divs that I would like to line up vertically, unfortunately every solution I find only uses either position:absolute or flexbox and I cannot use either because it will affect other things on the page that I do not have control over.
At the moment here is my code:
<div
class="search-wrapper text-center "
style=""
>
<div
class="col-md-7 perfect-vacation white "
style="font-family:lora;letter-spacing:0px;font-style:italic;font-size:clamp(1.3rem, 3.9vw, 2.9em);white-space:nowrap;"
>
<div> find your perfect cruise vacation</div>
</div>
<div id="search-cruises" class=" col-md-2" style="">
<a
href="/search-cruise/cruises"
class="green-btn button"
data-track="search-track"
data-track-id="search-widget"
style="background:#6D9D5B;padding:10px;
border-color:#6D9D5B;font-size:clamp(1.1em, 1vw, 1.4em);white-space:nowrap;"
>
Search Cruises
</a>
</div>
<div class="col-md-3" style="">
<a
class="white recent-cruise "
style="font-family:Roboto;white-space:nowrap;font-size:clamp(.8em, 1vw, 1.4em);color:white;overflow:visible;"
>
See Recently Viewed Cruises
</a>
</div>
</div>
Which looks like this (without the red line) I am looking to get all 3 items to line up with that red line. Any suggestions would be very much appreciated.
If you don't want to use flexbox (which would make it very easy) you can use inline-block with vertical-align:middle; and line-height.
a working abstract example
:root {
--nav-height: 100px;
}
.col {
text-align: center;
background-color: gray;
height: var(--nav-height);
}
.col > div {
display: inline-block;
vertical-align:middle;
line-height:var(--nav-height);
width: 25%;
background: lightgreen;
}
.d1 {
font-size:30px;
}
.d2 {
font-size:10px;
}
.d3 {
font-size:50px;
}
<div class="col">
<div class="d1">text 1</div>
<div class="d2">text 2</div>
<div class="d3">text 3</div>
</div>
This question already has answers here:
How to vertically align an image inside a div
(37 answers)
Center image using text-align center?
(28 answers)
Flexbox: center horizontally and vertically
(14 answers)
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
Closed 2 years ago.
I am trying to create circle cards using HTML and CSS. Upon click I am trying to open a web URL which is working perfectly fine for me.
But then I am not able set the alignment properly.
I tried display: flex to get the images side by side but the space between circle card is more but minimize space?
And I am not able to set the name of the circle in the center of the image. Can anyone please help me how to do this?
.circle {
background: rgba(15, 28, 63, 0.125);
border-radius: 50%;
height: 8em;
object-fit: cover;
width: 8em;
}
h1 {
text-align: center;
}
.row {
display: flex;
}
.circle-one, .circle-two, .circle-three {
flex: 33.33%;
padding: 5px;
}
<div>
<!-- your widget template -->
<h1> Hello World </h1>
<div class="row">
<div class="circle-one">
<a href="{{data.my_profile_url}}" target="_blank">
<img class="circle" src="https://images.unsplash.com/photo-1555448248-2571daf6344b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" alt="Tyler">
</a>
<h5> Circle One</h5>
</div>
<div class="circle-two">
<a href="{{data.my_profile_url}}" target="_blank">
<img class="circle" src="https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDk0fQ&auto=format&fit=crop&w=1000&q=80" alt="Tyler">
</a>
<h5> Circle Two</h5>
</div>
<div class="circle-three">
<a href="{{data.my_profile_url}}" target="_blank">
<img class="circle" src="https://cdn.pixabay.com/photo/2015/02/24/15/41/dog-647528_960_720.jpg" alt="Tyler">
</a>
<h5>Circle Three</h5>
</div>
</div>
</div>
This is what I get
use display flex
use align-items:center
.circle {
background: rgba(15, 28, 63, 0.125);
border-radius: 50%;
height: 8em;
object-fit: cover;
width: 8em;
}
h1 {text-align: center;}
.row {
display: flex;
align-items:center;
justify-content:space-around;
}
.circle-one, .circle-two, .circle-three {
flex: 33.33%;
padding: 5px;
display:flex;
flex-direction:column;
align-items:center;
}
<div>
<!-- your widget template -->
<h1> Hello World </h1>
<div class="row">
<div class="circle-one">
<a href="{{data.my_profile_url}}" target="_blank">
<img class="circle" src="https://images.unsplash.com/photo-1555448248-2571daf6344b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80" alt="Tyler">
</a>
<h5> Circle One</h5>
</div>
<div class="circle-two">
<a href="{{data.my_profile_url}}" target="_blank">
<img class="circle" src="https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDk0fQ&auto=format&fit=crop&w=1000&q=80" alt="Tyler">
</a>
<h5> Circle Two</h5>
</div>
<div class="circle-three">
<a href="{{data.my_profile_url}}" target="_blank">
<img class="circle" src="https://cdn.pixabay.com/photo/2015/02/24/15/41/dog-647528_960_720.jpg" alt="Tyler">
</a>
<h5> Circle Three</h5>
</div>
</div>
</div>
well, It is quite a simple task,
can be done in many ways. one of them is,
add div around your text (circle one , circle two, and circle three) and (img + a) tag
and apply css properties to the classes in css.
display: flex;
align-items: center;
justify-content-center;
This question already has answers here:
CSS Multistep Progress bar
(1 answer)
Build Step Progress Bar (css and jquery)
(8 answers)
Closed 5 years ago.
I have 3 images with same width and 1 image with slightly bigger width, and i want to show those images in a row, and between those images there's a connecting line horizontal in the middle, and one of the connecting line will have different color, roughly like this:
What i've done so far is i used <hr> as a connecting line but it seems not good looking enough, the connecting line not aligning vertical in the middle and when i tried to increase the font-size below each image it will make 2 row font-line not 1.
<style>
.rank-images .image-container{
width: 14%;
display: inline-block;
}
.rank-images .image-container.rank-3{
width: 18%;
}
div.seperator{
display: inline-block;
width: 12%;
}
div.seperator hr{
border-bottom: 3px solid #F7D85A;
}
div.seperator.third-seperator hr{
border-bottom: 3px solid #333;
}
.rank-images .image-container p{
margin-top: 15px;
text-align: center;
}
.rank-images .image-container p span{
font-weight: bold;
font-size: 0.73em;
color: #333;
}
</style>
<div class="rank-images">
<div class="image-container rank-1">
<img class="rank-image" src="https://cdn.pixabay.com/photo/2016/02/19/15/34/orange-1210523_960_720.png" />
<p>
<span>Less than 2000 points</span>
</p>
</div>
<div class="seperator first-seperator">
<hr>
</div>
<div class="image-container rank-2">
<img class="rank-image" src="https://cdn.pixabay.com/photo/2016/02/19/15/34/orange-1210523_960_720.png" />
<p>
<span>2001 - 5000 points</span>
</p>
</div>
<div class="seperator second-seperator">
<hr>
</div>
<div class="image-container rank-3">
<img class="rank-image" src="https://cdn.pixabay.com/photo/2016/02/19/15/34/orange-1210523_960_720.png" />
<p>
<span>5001 - 12000 points</span>
</p>
</div>
<div class="seperator third-seperator">
<hr>
</div>
<div class="image-container rank-4">
<img class="rank-image" src="https://cdn.pixabay.com/photo/2016/02/19/15/34/orange-1210523_960_720.png" />
<p>
<span>More than 12000 points</span>
</p>
</div>
</div>
I have a grid divided into 2. One side holds an image and the other side some text. Currently it looks as follows:
I want to make it look as follows:
I am looking to get rid of the black spot and center the text. There is no issue in centering it horizontally but unable to do it vertically to fit nicely in relation to the image. Please advice if there is any pre built class already available in bootstrap or I need to rewrite additional CSS.
The following are my current html and css.
HTML
<div class="col-md-6 custom-info">
<img src="img/test.jpg" class="img-responsive center-block">
</div>
<div class="col-md-6 custom-info text-center" style="text-align: left;">
<h1>Discover Our Latest Colourful addition</h1>
<h3>Explore our range of text text text text.</h3>
<h3>View the menu.</h3>
</div>
CSS
.custom-info{
background-color: #c0d023;
padding: 30px;
}
After Editing:
You may try this.
HTML
<div class="row xclassrow">
<div class="col-md-6 custom-info">
<img src="http://i.imgur.com/VpelmxT.png?1" class="img-responsive center-block">
</div>
<div class="col-md-6 custom-info text-left">
<div class="content">
<h1>Discover Our Latest Colourful addition</h1>
<h3>Explore our range of text text text text.</h3>
</div>
<h3>View the menu.</h3>
</div>
CSS
.xclassrow{
background-color:#C0D123
}
.content {padding:40px 0px}
.custom-info{
background-color: #c0d023;
padding: 30px;
}
Hope this works. Do comeback if still any issue.!!
EDIT : Removed the xclass and wrap the content in a new class. Check DEMO
TLDR;
Use display:table with display:table-cell to accomplish vertical centering of elements.
For newer browser you can use flexbox. I will demonstrate both approaches here.
Old but secure way (may not work for you here)
What I do most of the time is define 2 helper classes called t and td
*This works if you have a defined height of the containing element
The code then looks something like this:
HTML
<div class="col-md-6 custom-info text-center" style="text-align: left;">
<div class="t">
<div class="td">
<h1>Discover Our Latest Colourful addition</h1>
<h3>Explore our range of text text text text.</h3>
<h3>View the menu.</h3>
</div>
</div>
</div>
CSS
.t {
display: table;
height: 100%;
}
.td {
display: table-cell;
vertical-align: middle;
height: 100%;
}
Jsfiddle
Old and even more secure way
Since you know that your 2 columns are 6+6 and that makes 12 columns total width.
Make 1 long element col-md-12 and make a table inside it (either with regular table elements or the helper classes i used in the above example.
HTML
<div class="col-12 specific-class">
<div class="t">
<div class="td">
<img src="http://static.adzerk.net/Advertisers/d936d243e9de4c989a6c95b031eb11d6.png" alt="">
</div>
<div class="td">
<h1>Discover Our Latest Colourful addition</h1>
<h3>Explore our range of text text text text.</h3>
<h3>View the menu.</h3>
</div>
</div>
</div>
CSS
.specific-class .td {
width: 50%;
background: rgba(0,0,0,.2);
}
.t { display: table; height: 100%; width: 100%; }
.td { display: table-cell; vertical-align: middle; height: 100%; }
Jsfiddle
Note: added vertical align to the image to remove small spacing under it
The mighty flexbox (the future looks bright)
Flexbox is a sight for sore eyes for us fe-devs and will be an integral building block of the future www.
HTML
<div class="col-12 specific-class">
<div class="fl-element">
<img src="http://static.adzerk.net/Advertisers/d936d243e9de4c989a6c95b031eb11d6.png" alt="">
</div>
<div class="fl-element">
<h1>Discover Our Latest Colourful addition</h1>
<h3>Explore our range of text text text text.</h3>
<h3>View the menu.</h3>
</div>
</div>
CSS
.specific-class {
display: flex;
align-items: center;
}
.specific-class .fl-element {
width: 50%;
}
Jsfiddle
The goal is that I want both images to have be side by side and centered in the middle of the row.
I tried to do that via adjusting the columns of the row
The problem is that even with trying to center via rows, it always looks a little off center and if I change the max-width to be a little bigger, the images are no longer side by side and are on top of one another
The height and width of the images are...
graft1/graft2 - height="333" width="500"
ivan1/ivan2 - height="542" width="400"
Here is my HTML
<section class="wrapper style1">
<div class="container">
<div id="content">
<!-- Content -->
<article>
<header>
<h2>Before and After</h2>
</header>
<div class="row">
<div class="div_baPics">
<img id="graft1" class="baPics" src="images/graft1.jpg" alt="">
<label for="graft1">Before</label>
<img id="graft2" class="baPics" src="images/graft2.jpg" alt="">
<label for="graft2">After</label>
</div>
</div>
<div class="row">
<div class="div_baPics">
<img id="ivan1" class="baPics" src="images/ivan1.jpg" alt="">
<label for="ivan1">Before</label>
<img id="ivan2" class="baPics" src="images/ivan2.jpg" alt="">
<label for="ivan2">After</label>
</div>
</div>
</article>
</div>
</div>
</section>
And here is the CSS for baPics
.baPics {
max-width: 30%;
}
.div_baPics {
text-align: center;
}
Since you're using Bootstrap, I went with its system. See this fiddle :
http://jsfiddle.net/Bladepianist/55gyp94n/
Well, i did use real image so that you could see the result but with that (when I tested anyway), your image should resize, following the screen.
.thumbnail {
border: none;
}
This code isn't needed, unless you don't want the border of the thumbnail ;).
Hope it will satisfy you and if that's the case, thumbs up :p.
You need to wrap img and corresponding label in a wrapper, like so:
/*Just to make a difference between pics*/
body {
background: grey;
}
/*Minimal CSS*/
.div_baPics {
text-align: center; /*Center alignment for the wrapper*/
font-size: 0; /*To remove the white space between pics*/
}
.pic {
display: inline-block;
}
.pic img {
display: block;
/*This should be set by default by Bootstrap*/
max-width: 100%;
height: auto;
}
.pic label {
display: block;
font-size: 16px; /*Or whatever font-size you use*/
}
<div class="div_baPics">
<div class="pic">
<img src="http://i.imgur.com/zNTWaR3.jpg" />
<label>Pic 1</label>
</div>
<div class="pic">
<img src="http://i.imgur.com/IqiJN2f.png" />
<label>Pic 2</label>
</div>
</div>