Place Text on top of one another next to an image - html

I have the following html:
<div class="row">
<div col-md-9>
<div>
<img class="img-valign" src="an image">
<span class="text1" Style="font-size: 8pt">Text number 1</span>
<span class="text1" Style="font-size: 8pt">Text number 2</span>
</div>
</div>
<div col-md-3>
</div>
</div>
</div>
Is it possible this way to make text number two below text number 1 but on the right of the image? In this way the second span is going below the image.

You can easily achieve that using flexbox. Bootstrap also has built-in classes for that.
Your HTML structure needs to be changed slightly:
<div class="container">
<div class="row">
<div class="col-md-9">
<!-- justify-content-between makes img and the text list stay left and right -->
<div class="d-flex flex-row justify-content-between">
<img />
<!-- flex-column makes this text list display its children as column -->
<div class="d-flex flex-column">
<span />
<span />
</div>
</div>
</div>
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/gvs8yp6r/6/
If you want to align the text list and the image to their center as well, just add .align-items-center to the parent flex container:
<div class="container">
<div class="row">
<div class="col-md-9">
<!-- this div is the parent flex container -->
<div class="d-flex flex-row justify-content-between align-items-center">
<img />
<div class="d-flex flex-column">
<span />
<span />
</div>
</div>
</div>
</div>
</div>
demo: https://jsfiddle.net/davidliang2008/gvs8yp6r/8/

#rightText {
margin-left: 50%;
font-size: 8pt;
}
<div class="row">
<div col-md-9>
<div>
<img class="img-valign" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
<div id ="rightText">
<span class="text1" Style="font-size: 8pt">Text number 1</span>
<br>
<span class="text1" Style="font-size: 8pt">Text number 2</span>
</div>
</div>
</div>
<div col-md-3>
</div>
</div>
</div>

Related

Extra Space in Bootstrap

I am writing in HTML, using Bootstrap 5. I am trying to make a simple row of cards, however there is a lot of empty padding/space. How do I remove this?
Extra Space between cards
Here is my code:
Code\
<div class="row">
<div class="col">
<div onclick="locations(2)" id="location-2" class="w-75 custom-card">
<div class="card-body">
<h5>
<div class="row">
<div class="col">
<img style="border-radius: 5px;" src="https://flagcdn.com/fi.svg" width=40 height=30>
</div>
<div class="col">
<span class="fs-5" style="margin-left:-30px;line-height:-20px;">Helsinki,</span><br><span style="margin-left:-30px;line-height:-20px;" class="fw-normal fs-6">Finland</span>
</div>
</div>
</h5>
</div>
</div>
</div>
<div class="col">
<div onclick="locations(2)" id="location-2" class="w-75 custom-card">
<div class="card-body">
<h5>
<div class="row">
<div class="col">
<img style="border-radius: 5px;" src="https://flagcdn.com/fi.svg" width=40 height=30>
</div>
<div class="col">
<span class="fs-5" style="margin-left:-30px;line-height:-20px;">Helsinki,</span><br><span style="margin-left:-30px;line-height:-20px;" class="fw-normal fs-6">Finland</span>
</div>
</div>
</h5>
</div>
</div>
</div>
</div>
I tried using g-0 in the row, however it did not change at all.

How to truncate text with screen size using ellipses

I have this Stackblitz and the Stackblitz Url that has 2 bootstrap cards inside a page layout with columns.
Problem - With the Name (.card-title) of the card being greater than 11 characters longs (max 15), when I shrink the screen between 768px-1200px the name at the top of the card squishes the star/rating down to the next line.
Question - Is there a way to truncate the name (ex. AnneMariesPlace) between 768px-1200px with ellipses, so that the star/rating remains on the same line?
ex. AnneMari...
This would mean the max length would be 8 plus the ellipses (3 chars)
Can it be done with pure CSS using?
FYI - I tried a couple of things with text-overflow: ellipsis; and white-space: nowrap;
but I didn't have much luck.
Here is the code I'm using
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<div class="container my-3 my-xl-5">
<div class="row">
<div class="col-lg-3">
something here
</div>
<div class="col-lg-9">
<div class="row">
<div class="col">
<div class="mb-4">
</div>
<div class="row row-cols-1 row-cols-sm-2">
<div class="col mb-4">
<div class="card">
<div class="row no-gutters">
<div class="col-md-5">
<img class="yogaband-img img-fluid w-100" style="object-fit: cover; object-position: center; min-height: 100%;" src="https://res.cloudinary.com/k9dapp/image/upload/c_scale,w_1450,h_1450/f_auto/v1569538700/mainpage/iStock-860080282_bkhfsu.jpg" alt="yogaband">
</div>
<div class="col-md-7">
<div class="card-body py-1">
<div class="row">
<div class="col-12">
<b class="card-title d-inline">AnneMariesPlace</b>
<span class="float-right center-star">
★3.43
</span>
</div>
</div>
<div class="row">
<div class="col-12">
<span>Access</span>
<span class="float-right">Private</span>
</div>
<div class="col-12">
<span>Max Size</span>
<span class="float-right">10</span>
</div>
<div class="col-12">
<span>Events</span>
<span class="float-right">323</span>
</div>
<div class="col-12">
<span>Type</span>
<span class="float-right">Park</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col mb-4">
<div class="card">
<div class="row no-gutters">
<div class="col-md-5">
<img class="yogaband-img img-fluid w-100" style="object-fit: cover; object-position: center; min-height: 100%;" src="https://res.cloudinary.com/k9dapp/image/upload/c_scale,w_1450,h_1450/f_auto/v1569538700/mainpage/iStock-860080282_bkhfsu.jpg" alt="yogaband">
</div>
<div class="col-md-7">
<div class="card-body py-1">
<div class="row">
<div class="col-12">
<b class="card-title d-inline">AnneiMaries</b>
<span class="float-right center-star">
★3.43
</span>
</div>
</div>
<div class="row">
<div class="col-12">
<span>Access</span>
<span class="float-right">Private</span>
</div>
<div class="col-12">
<span>Max Size</span>
<span class="float-right">10</span>
</div>
<div class="col-12">
<span>Events</span>
<span class="float-right">323</span>
</div>
<div class="col-12">
<span>Type</span>
<span class="float-right">Park</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
To make ellipsis work you need conditions. First, the element must NOT be inline. Yours it is even with an !important condition (which I don't know why you set it), second it needs a width set (it does not matter if percent or fixed) and last, it needs overflow:hidden and white-space:nowrap (so the content won't ever take a second line).
Basically, and based on your example, you need this:
.d-inline {
display: inline-block;
overflow: hidden;
width: calc(100% - 44px);
white-space: nowrap;
}
Unfortunately, it looks like your "score" will never get more width space than 44px. Use a bit more to feel safe just in case (browser zooming and such.)

Left Align Badges

I have created this card here in which i have some badges but they are not aligned in the right way i need to left align them like this image.. Can anyone help me in aligning these badges just like they are aligned in the second image? I am using bootstrap 3.3.7 and this just a little code snippet and i think this is enough information.
here is the html code.
<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="col-sm-6">
<div class="card main-content">
<div class="row clearfix" id="line">
<div class="col-sm-12">
<div class="header">
<h2>
Insights
</h2>
</div>
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-12" style="display: table;">
<div>
Total Students
<span class="badge badge-primary">
0
</span>
</div>
<br>
<div>
Subjects
<span class="badge badge-primary">
20
</span>
</div>
<br>
<div>
Sections
<span class="badge badge-primary">
289
</span>
</div>
<br>
<div>
Created On
<span class="badge">
27/8/2018
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You can wrap your labels in a <span> tag and give it a min-width. This way, the badges will be horizontally left aligned and vertically on the same line:
.insight-label {
display: inline-block;
min-width: 120px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-sm-6">
<div class="card main-content">
<div class="row clearfix" id="line">
<div class="col-sm-12">
<div class="header">
<h2>Insights</h2>
</div>
<div class="modal-body">
<div class="row clearfix">
<div class="col-sm-12" style="display: table;">
<div>
<span class="insight-label">Total Students</span>
<span class="badge badge-primary">0</span>
</div>
<br>
<div>
<span class="insight-label">Subjects</span>
<span class="badge badge-primary">20</span>
</div>
<br>
<div>
<span class="insight-label">Sections</span>
<span class="badge badge-primary">289</span>
</div>
<br>
<div>
<span class="insight-label">Created On</span>
<span class="badge">27/8/2018</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Stick image to side responsive bootstrap

I am trying to create this:
I have the left and right image and the monkey image.
I was trying to create a row and make the left image col-3, the right image col-3 and the monkey and text col-6 in the middle.
Everything is stacking up on each other, comes out of the screen and not working. How can I make this sort of thing?
<section class="hero-area">
<div class="container-fluid">
<div class="row">
<div class="col-md-3 col-xs-3">
<img src="images/hero-left.svg" class="" alt="">
</div>
<div class="col-xs-6 col-md-126>
<h1 class="">
<b>monKey</b> Generator</h1>
<br>
<h2 class="">Generate a
<b>unique monkey</b> avatar
<br> from a
<b>Banano public key</b>
</h2>
<img src="https://bananomonkeys.herokuapp.com/image?address=ban_3tapge8i4kw9wa4irgda7epm4gaurr4rnp7ybjziphkt48afd6ba5pnaegs6"
class="" alt="">
</div>
<div class="col-md-3 col-sm-3">
<img src="images/hero-right.svg" class="" alt="">
</div>
</div>
</div>
</section>
There are couple of typos in your snippet above eg: col-md-126 and missing " after that. Also bootstrap 4 does not have xs on cols so using just col-3 col-6 col-3 would do the job.
See the snippet below.
img {
width:100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<section class="hero-area">
<div class="container-fluid">
<div class="row">
<div class="col-3">
<img src="images/hero-left.svg" alt="monkey left">
</div>
<div class="col-6">
<h1>
<b>monKey</b> Generator
</h1>
<br>
<h2>Generate a
<b>unique monkey</b> avatar
<br> from a
<b>Banano public key</b>
</h2>
<img src="https://bananomonkeys.herokuapp.com/image?address=ban_3tapge8i4kw9wa4irgda7epm4gaurr4rnp7ybjziphkt48afd6ba5pnaegs6" />
</div>
<div class="col-3">
<img src="images/hero-right.svg" class="" alt="monkey right">
</div>
</div>
</div>
</section>

How to fill the gap of a div without using media query?

I'm using bootstrap cards to build this layout on desktop:
So far so good, at this width everything is ok as well:
But from this width to desktop width the container is not filled:
The HTML to build the card with the images is:
<div class="card h-60">
<div>
<div class="row box">
<div class="box-content formal">
<div class="col-md-12">
<img class="imageban" src="img/crm.png" />
<span><b>CRM</b></span>
</div>
</div>
<div class="box-right">
<a href="#">
<img class="img-responsive" src="img/img1.jpg"/>
</a>
</div>
</div>
</div>
<div>
<div class="row box">
<div class="box-content report">
<div class="col-md-12">
<img class="imageban" src="img/report.png" />
<span><b>Report</b></span>
</div>
</div>
<div class="box-right">
<a href="#">
<img class="imageban" src="img/img4.jpg"/>
</a>
</div>
</div>
</div>
<div>
<div class="row box">
<div class="box-content formal">
<div class="col-md-12">
<img class="img-responsive" src="img/formal_notices.png" />
<span><b>Formal Notices</b></span>
</div>
</div>
<div class="box-content text">
<a href="#">
Open the Formal <br>Notice Document <br>Library
</a>
</div>
</div>
</div>
</div>
And the CSS is only this line:
.row.box{
max-width: 345px;
}
I'm stuck in this, any help would be nice. Thanks.
You can remove the class .box and use the Bootstrap classes instead col-md-4 col-xs-12.