Bootstrap (CSS) - Overlay One Img over another using responsive design - html

What CSS do I need to use so that one img "under construction" is overlayed in the top left corner of the 1st image. The section of script this pertains to is the second column in the row. I've tried various solutions using position in css but have come up with nothing that is consistent with page resizing. I need a responsive solution.
<div class="col-lg-6">
<h2 class="text-center">Current Conditions</h2>
<img src="#Url.Content("~/Content/Img/weather4.png")" id="current-weather-logo" class="img-responsive center-block" />
<p class="text-center">View the current weather conditions in relation to Crestwood Assets</p>
<p class="text-center">
Launch <span class="glyphicon glyphicon-chevron-right"></span>
Documentation <span class="glyphicon glyphicon-chevron-right"></span>
</p>
</div>
<div class="col-lg-6">
<h2 class="text-center">Historical Weather</h2>
<img src="#Url.Content("~/Content/Img/weather4.png")" id="current-weather-logo" class="img-responsive center-block" />
<img src="#Url.Content("~/Content/Img/under-construction.png")" id="under-construction" class="img-responsive center-block img-overlay" />
<p class ="text-center">Leverage historical weather data for analysis with asset data.</p>
<p class ="text-center">
Launch <span class="glyphicon glyphicon-chevron-right"></span>
Documentation <span class="glyphicon glyphicon-chevron-right"></span>
</p>
</div>
</div>
EDIT
I modified to include the images in a div and provided some additional CSS.
<div id="img-container">
<img src="#Url.Content("~/Content/Img/weather4.png")" id="current-weather-logo" class="img-responsive center-block" />
<img src="#Url.Content("~/Content/Img/under-construction.png")" id="under-construction" class="img-responsive center-block img-overlay" />
</div>
.img-overlay{
position:absolute;
top:0;
left:0;
z-index:3;
}
#img-container{
position:relative;
}
EDIT 2
I attempted to fit it using the top and left attributes:
.img-overlay{
position:absolute;
top:0;
left:14.5%;
z-index:3;
}
This worked great at my initial width but when sized down to a smaller window it is pushed in. I would like to be consistent.

Here's how to put a picture above another picture: http://codepen.io/ruchiccio/pen/ZWZEEy
More than that I can't help because you haven't supplied normal paths to images so we can't see what should go onto what. Maybe provide a screenshot of what you'd like.
<div id="container">
<img id="pic1" src="http://placehold.it/350x150">
<img id="pic2" src="http://placehold.it/150x50">
</div>
#container {
position: relative;
}
#pic2 {
position: absolute;
top: 0;
left: 0;
z-index: 3;
}

Related

How to align text on the right side of an image in the header

So, I am trying to get the body text inside the red box that I added in the image attached. It seems like no matter what I do, it just keeps moving down.
Here is the code:
<div class="catalog-center-width one-col-full">
<div class="top-row-grey top-row-white-v2 padding-top padding-side row-v2">
<div class="row dp-row-flex-v2">
<div class="columns large-6 text-center dp-promo-image-wrapper"><img src="https://everpath-course-content.s3-accelerate.amazonaws.com/instructor%2F3vkvwjz9hnng2dhlfwzj2a5lt%2Fpublic%2F1666809704%2F6527-q2retarget-hc.1666809704408.png" alt="" width="529" height="360" align="left" /></div>
<h1 class="break-word">
<strong>Get started with Ally Lending basics</strong>
</h1>
<div class="sj-course-info-wrapper">
<h2>Find and start conversations, collaborate effectively in channels, find information you need, keep work organized with channels and keep your sidebar organized in Slack.</h2>
<div id="purchase-button-wrapper-large" class="purchase-button-wrapper">
<a class="medium button purchase-button login-link free" href="/checkout/1ycnoni7kt1cn">
<span class="purchase-button-full-text"> Get Started </span>
</a>
</div>
</div>
</div>
</div>
</div>
<div id="purchase-button-wrapper-large" class="purchase-button-wrapper">
<div id="purchase-button-wrapper-large" class="purchase-button-wrapper">
<!-- START Walkthrough developer center tile design,
add to page source code -->
</div>
</div>
html,body,h1,h2,h3 {
padding:0;
margin:0;
}
.container {
width:100%;
max-width:80vw;
margin:0 auto;
display:flex;
align-items:center;
justify-content:center;
gap:4rem;
}
.left-col {
width:30%;
}
.left-col img {
width:100%;
height:auto;
}
.right-col {
display:flex;
flex-direction:column;
width:70%;
border:1px solid red;
padding:2rem;
}
<div class="container">
<div class="left-col">
<img src="https://everpath-course-content.s3-accelerate.amazonaws.com/instructor%2F3vkvwjz9hnng2dhlfwzj2a5lt%2Fpublic%2F1666809704%2F6527-q2retarget-hc.1666809704408.png" alt="" width="529" height="360" align="left" />
</div>
<div class="right-col">
<h1 class="break-word"><strong>Get started with Ally Lending basics</strong></h1>
<h2>Find and start conversations, collaborate effectively in channels, find information you need, keep work organized with channels and keep your sidebar organized in Slack.</h2>
<div id="purchase-button-wrapper-large" class="purchase-button-wrapper">
<a class="medium button purchase-button login-link free" href="/checkout/1ycnoni7kt1cn"><span class="purchase-button-full-text"> Get Started </span>
</a>
</div>
</div>
</div>
<div id="purchase-button-wrapper-large" class="purchase-button-wrapper">
<div id="purchase-button-wrapper-large" class="purchase-button-wrapper">
<!-- START Walkthrough developer center tile design,
add to page source code -->
</div>
</div>

Bootstrap - Badge in Img mantain responsive

I need a badge within an img - independently from the window size - So far I have in my html following code (btw. I'm using Angular - but framework should be irrelevant):
.icon-container {
display: inline-block;
position: relative;
}
troop-level-badge {
position: absolute;
bottom: 2px;
left: 2px;
}
`
<div class="container row" *ngIf="img">
<div class="col-md-1">
<div class="icon-container">
<img class="rounded" [src]="img" width="40" height="auto">
<span class="badge badge-dark troop-level-badge">6</span>
</div>
</div>
</div>`
so far the result looks like this (as expected):
But when i resize the window the badge breaks out of the div. Does
someone know how i can contain the badge within the img even by resizing the window?
Your troop-level-badge rule isn't valid. There is a missing point. So replace troop-level-badge with .troop-level-badge and it should work like the following. To display the badge on the right side you need to set right:2px; instead of left:2px;:
.icon-container {
display:inline-block;
position:relative;
}
.troop-level-badge {
bottom:2px;
position:absolute;
right:2px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<div class="container row" *ngIf="img">
<div class="col-md-1">
<div class="icon-container">
<img class="rounded" src="https://placehold.it/100x100" >
<span class="badge badge-dark troop-level-badge">6</span>
</div>
<div class="icon-container">
<img class="rounded" src="https://placehold.it/75x75" >
<span class="badge badge-dark troop-level-badge">6</span>
</div>
<div class="icon-container">
<img class="rounded" src="https://placehold.it/50x50" >
<span class="badge badge-dark troop-level-badge">6</span>
</div>
</div>
</div>

Placement of a div tag does not work

I am working on my portfolio. I have this page here:
The first picture there is a date on. I would like a text in the bottom, like this:
But I cannot get that text placed. Everytime I add a div tag and set in a text, it is going outside of the picture. I guess it is a div tag there has to be somewhere?
<div class="portfolio logo" data-cat="logo">
<article class="block-thumbnail">
<a href="#" class="block-thumb">
<div class="date">
<span class="day">10</span>
<span class="month">aug</span>
<span class="month">2016</span>
</div>
</a>
<div class="portfolio-wrapper">
<div class="portfolio-hover">
<div class="image-caption">
<div class="col-md-4 col-sm-6 col-xs-12">
<h2>link</h2>
</div>
</div>
<img src="img/portfolios/logo/5.jpg" alt="" />
</div>
</div>
</div>
If we are talking about the h2 element, that html tag sits inside a element that is hidden by default and only appears on hover.
I will move it outside the .image-caption div
<div class="portfolio-wrapper">
<div class="portfolio-hover">
<div class="col-md-4 example col-sm-6 col-xs-12">
<h2>link</h2>
</div>
<div class="image-caption">
</div>
<img src="img/portfolios/logo/5.jpg" alt="" />
</div>
</div>
and give it those styles
.example {
position: absolute;
bottom: 0;
z-index: 1;
text-align: center;
left: 0;
}
Adjust than bottom and left values to match the positioning for your design
You'll have to create a css for your image-caption class, that will be in absolute position, meaning it can clash with other things. This should help you with that: Position absolute but relative to parent . Then just make sure you have your z-index right so it's not behind the image

WooCommerce Single Product Image not getting centered

I have a three column layout and one of them is like -
<div class="column one-second product_image_wrapper">
<div class="images">
<div class="image_frame scale-with-grid" ontouchstart="this.classList.toggle('hover');">
<div class="image_wrapper">
<a href="#" itemprop="image" class="woocommerce-main-image zoom" title="Sumanji Kamphy" data-rel="prettyPhoto">
<div class="mask">
</div>
<img width="250" height="250" src="#" class="scale-with-grid wp-post-image" alt="Sumanji Kamphy" title="Sumanji Kamphy">
</a>
<div class="image_links">
<a href="#" itemprop="image" class="woocommerce-main-image zoom" title="Sumanji Kamphy">
<i class="icon-search">
</i>
</a>
</div>
</div>
</div>
</div>
</div>
I want to center this image both vertically and horizontally currently it looks something like this -
Can someone tell how to do this ?
Assuming that you want to put it in center with relative to the div with class image_frame , the following code will work.
.image_frame{
position:relative;//makes the outer div as relative, thus you can use which if you want some other div
}
.image_frame img{
position:absolute;
top:50%;
left:50%;//brings the edge of image to exact center both horizontally and vertically
margin-top:-125px;
margin-left:-125px;//Now pushing it half of images width and height in your case it is 250px so -125px is good for pushing the image to exact center.
}

Transparent layer of text over an image

I have the following markup:
<div class="photo" style="float: left; margin: 2px;">
<a href="#">
<img src="images/image.jpg" alt="My Image" height="240" width="240" />
</a>
</div>
How can I create a layer on top of the image where I can write some text? The layer should have transparency, be aligned to bottom and having a size of 240x60?
Thanks!
Why not make the image a background?
<div class="photo" style="float:left; margin:2px">
<a href="#" style="background:url('images/image.jpg');
width:240px; height:240px; display:inline-block;">Your text here</a>
</div>
The display:inline-block allows you to apply width and height to an otherwise inline element, but here you might even want to just use display:block since it's the only child of the container.
EDIT: You can even put more containers in it, something like this:
<div class="photo" style="float:left; margin:2px">
<a href="#" style="background:url('images/image.jpg'); position:relative;
width:240px; height:240px; display:block;">
<span style="display:block;position:absolute;bottom:0;left:0;right:0;
background:white;background:rgba(255,255,255,0.25);">Your text here</span>
</a>
</div>
Text blocks over images. Website and demo as follows:
http://css-tricks.com/text-blocks-over-image/
I'll do it like with an image container like that :
Html
<div class="image-container">
<img src="path/to/image" />
<p class="caption">My text</p>
</div>
CSS
.image-container {
position:relative;
}
.caption {
width:100%;
background:rgba(0,0,0,0.5);
color:#ffffff;
position:absolute;
top:0;
}
See fiddle !
Markup
<div class="figure-container">
<img src="http://ipadwallsdepot.com/detail/solid-color_00015061.jpg" width="250" height="250" />
<span class="figure-label">FIG 1.1: Caption Text Here</span>
</div>
<div class="figure-container">
<img src="http://ipadwallsdepot.com/detail/solid-color_00015061.jpg" width="250" height="250" />
<span class="figure-label">FIG 1.2: Another Caption Here</span>
</div>
Stylesheet
.figure-container
{
position: relative;
display: inline-block;
}
.figure-label
{
position: absolute;
bottom: 10px;
right: 10px;
color: White
}
I created a JSFiddle here http://jsfiddle.net/AbBKx/ showing how to absolutely position a child element (label) relative to a parent container.