I want to add an image over an image.
For example, there's an image in the background and on top of that i need to add an image of a play button. Where the user can play the video by clicking on it. This is also shown on the Shopify homepage.
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img width='100%'
src='http://roomista.com/uploads/hotel-gal/250_SunwayHotelHanoiSuperiorRoom.jpg' />
<div class='img-container'>
<div class='img-text'>
<img src="http://lizkhoo.com/content/play-icon.png" alt="..." />
</div>
</div>
And the CSS is as follows:
.img-container {
width: 100%;
position: relative;
display: inline-block;
margin: 10px 5px 5px;
}
.img-text {
width: 100%;
display: block;
}
Use position: relative on .item and position: absolute on .img-text.
You should not need to use z-index on .img-text, but if it appears under .img-container, use it.
.img-text {
/*position: absolute;*/ Wrong, see edit
width: 100%;
display: block;
/*top: ?; bottom: ?; left: ?; right: ?; //to place it as you want.*/
}
.item{
position: relative;
}
Edit : I misread your code, (badly indented :p)
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img width='100%'
src='http://roomista.com/uploads/hotel-gal/250_SunwayHotelHanoiSuperiorRoom.jpg' />
<div class='img-container'>
<div class='img-text'>
<img src="http://lizkhoo.com/content/play-icon.png" alt="..." />
</div>
</div>
</div>
</div>
So position: absolute on .img-container
.img-container {
position: absolute;
top: ?; bottom: ?; left: ?; right: ?; //to place it as you want.
}
Edit 2 :
A little jsFiddle, like the comment below : http://jsfiddle.net/hsYwV/1/
The easiest way to do this is to set the image as a background.
html:
<div class="item-active">
<img class='img-text' src="http://lizkhoo.com/content/play-icon.png" />
</div>
css:
.item-active {
width: 200px;
height: 200px;
background-image: url('http://roomista.com/uploads/hotel-gal/250_SunwayHotelHanoiSuperiorRoom.jpg');
}
.img-text {
position: relative;
left: 75px;
top: 75px;
width: 50px;
height: 50px;
}
JScript:
$(".img-text").bind("click", function(){
alert("play video");
});
http://jsfiddle.net/J7qnF/2/
Related
What element do I need to create black lines in the image ? [![enter image description here][1]][1]
I have written code but I need lines like image (create between images) how can I do this?
Please tell me
My codes are as follows:
using ":after" & ":before" you can set line between two images
.hiw-content .hiw-img img {
width: 100%;
height: auto;
padding: 100px;
}
div#a3:after {
z-index: 999;
content: '';
width: 150px;
background-color: black;
/* left: 0; */
height: 5px;
position: absolute;
right: -80px;
top: 50%;
border-radius: 100px;
}
div#a3:before {
z-index: 999;
content: '';
width: 150px;
background-color: black;
left: -80px;
height: 5px;
position: absolute;
/* right: 50%; */
top: 50%;
border-radius: 100px;
}
div#a3 {
overflow: visible;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="wrapper">
<div class="col-md-4 col-hiw col-hiw-bottom" id="a4">
<div class="hiw-content">
<div class="hiw-img"><img src=""></div>
<span class="hiw-title">Customer Service</span>
<p class="hiw-content">Let our dedicated customer service team take care of any inquiries</p>
</div>
</div>
<div class="col-md-4 col-hiw col-hiw-bottom" id="a3">
<div class="hiw-content">
<div class="hiw-img"><img src=""></div>
<span class="hiw-title">Order fulfilled</span>
<p class="hiw-content">Once a buyer places an order we’ll take care of order production and shipping.</p>
</div>
</div>
<div class="col-md-4 col-hiw col-hiw-bottom" id="a2">
<div class="hiw-content">
<div class="hiw-img"><img src=""></div>
<span class="hiw-title">Boost your sales</span>
<p class="hiw-content">Use Teesprings Boosted Network, Marketing Tools and Partnership Integrations </p>
</div>
</div>
</div>
It is easier to help you if you included more detailed code, the code above really doesn't help, to create a simple line you can do something like this (adjust margin and height/width appropriately) :
.underline {
width: 5rem;
height: 0.25rem;
background: #000;
}
<div class="underline"></div>
I want a responsive img with text on top. Ive tried several different ways and I semi-get there with a bunch of kinks when I try to make it responsive, so I appreciate if anyone has a simple solution.
JSFiddle
Code snippet demonstration :
.img-fluid {
max-width: 100%;
height: auto;
opacity: 0.4;
}
<div class="container">
<img src="https://phillipbrande.files.wordpress.com/2013/10/random-pic-14.jpg?w=620" class="img-fluid">
<div class="container">
<h1>Header</h1>
</div>
</div>
You can try this , here is the code
<html>
<head>
<style>
.container {
position: relative;
text-align: center;
color: white;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<h2>Image Text within container</h2>
<div class="container">
<img src="abc.jpg" alt="abc" style="width:100%;">
<div class="centered">Centered</div>
</div>
</body>
You can make use of font-size: calc(2vw + 2vh + 2vmin) (tweak around the values to your need) to make text responsive with respect to viewport size :)
.container {
position: relative;
}
.container h1 {
position: absolute;
top: 0;
left: 20px;
font-size: calc(2vw + 2vh + 2vmin);
}
.img-fluid {
max-width: 100%;
height: auto;
opacity: 0.4;
}
<div class="container">
<img src="https://phillipbrande.files.wordpress.com/2013/10/random-pic-14.jpg?w=620" class="img-fluid">
<h1>Header</h1>
</div>
Try setting position to absolute or fixed
.img-fluid{
max-width:100%;
height:auto;
opacity:0.4;
position: absolute;
}
HTML:
<div class="banner">
<img src="images/star.png" class="img-responsive" width="150" height="150" alt="star">
<h2>This is a Star</h2>
</div>
CSS:
.banner img{position:relative; width:100%; height:auto;}
.banner h2{[psition:absolute; left:50%; top:50%; font-size:30px;
line-height:30px;}
for an image use the concept:
{
display: table;
position: relative;
width: 100%;
height: auto;
}
for text to display on image use the concept
{
display: table-cell;
verticl-align: middle;
position: absolute;
}
and adjust the text on image giving top or bottom or left or right}
use the class img-responsive to not to change the width and height of image in all the views.
So, I have img inside div like this:
<div class="row text-center about__gallery">
<div class="col-xs-12 col-sm-4">
<div class="about__gallery--first img">
<img />
</div>
</div>
.
.
.
</div>
The effect I want to achieve is to have div with color exactly the same size as img behind it (on hover I'm gonna move img a little bit).
SCSS looks like this:
.about__gallery{
margin-top: 5%;
.img{
background-repeat:no-repeat;
background-size:cover;
width:70%;
height:230px;
margin-bottom: 15%;
img{
z-index: 3;
}
&:before {
position: absolute;
content: " ";
display: block;
width: 70%;
height: 230px;
background-color: $color-blue;
z-index: -100;
}
}
.about__gallery--first{
margin-left: 45%;
img{
content:url("../img/aboutus_pic1.png");
width: 100%;
}
}
.
.
Unfortunately result looks like this: DELETED DUE TO REPUTATION
Edit with full code:
<div class="row text-center about__gallery">
<div class="col-xs-12 col-sm-4">
<div class="about__gallery--first img">
<img class="about__gallery__img--bg" />
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="about__gallery--second img">
<img class="about__gallery__img--bg" />
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="about__gallery--third img">
<img class="about__gallery__img--bg" />
</div>
</div>
</div>
And my full .scss looks like this:
.about__gallery{
margin-top: 5%;
margin-bottom: 10%;
.img {
position: relative;
margin-bottom: 15%;
img {
width: 100%;
height: auto;
}
&:before {
position: absolute;
top: 0;
left: 0;
content: " ";
display: block;
width: 100%;
height: 100%;
background-color: $color-blue;
z-index: -100;
}
}
.about__gallery--first{
margin-left: 45%;
margin-bottom: auto;
img.about__gallery__img--bg{
content:url("../img/aboutus_pic1.png");
width: 100%;
}
}
.about__gallery--second{
margin:auto;
img.about__gallery__img--bg{
content:url("../img/aboutus_pic2.png");
width: 100%;
}
}
.about__gallery--third{
margin-left: -15%;
margin-bottom: auto;
img.about__gallery__img--bg{
content:url("../img/aboutus_pic3.png");
width: 100%;
}
}
}
And now my page looks like this:RESULT
My goal is to have something like that on my site:GOAL
Added hover that doesn't work........
codepen.io/Kreha/pen/vmbzPb
A few things I would do. First, remove the static height/widths that you have set. Let the container inherit them from the image. Then, you'll need to set the top/left position of the pseudo element, relative to the position of your container (which should be set to relative). Here's a working example.
<div class="row text-center about__gallery">
<div class="col-xs-12 col-sm-4">
<div class="about__gallery--first img">
<img src="http://placehold.it/250x250" />
</div>
</div>
</div>
.about__gallery {
margin-top: 5%;
.img {
position: relative;
margin-bottom: 15%;
img {
opacity: 0.8; // just to show the blue behind it
width: 100%;
height: auto;
}
&:before {
position: absolute;
top: 0;
left: 0;
content: " ";
display: block;
width: 100%;
height: 100%;
background-color: $color-blue;
z-index: -100;
}
}
&--first {
margin-left: 45%;
}
}
When i do css stuff i usually use Chrome Inspect Element to locate that particular element and try to change it's bg color and on the right side of CIE see css tab where you can see which class specifically is being effected so just simply call that class in your internal or external file and use an image as a background, hope it helps!
I changed the bg color of this current page we are working on, hehe!
.so-header~.container {
background-color: #ccc;
}
I would like to achieve the following:
Have a fluid container with one background color on each side - but the separator should be two cols in the inside container.
I tried to describe it in this picture. Is this even possible?
use css positions and after/before see the link below:
Codepen
.container {
background: #ddd;
height: 250px;
}
.extra1 {
height: 250px;
background: #fff;
position: relative;
z-index: 999;
}
.extra2 {
height: 250px;
background: #000;
}
.extra1:before {
content: '';
background: yellow;
position: absolute;
width: 300%;
top: 0px;
height: 100%;
left: -200%;
}
.extra2:before {
content: '';
background: green;
position: absolute;
width: 300%;
top: 0px;
height: 100%;
right: -200%;
}
.your-things {
position: absolute;
left: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-4 extra1">
<div class="your-things">
<p>.col-md-4</p>
</div>
</div>
<div class="col-md-8 extra2">
<div class="your-things">
<p>.col-md-8</p>
</div>
</div>
</div>
</div>
This can be done using psuedo element before and after on .container-fluid class or give any other class name.
Here is a code pen demo:
`http://codepen.io/duptitung/pen/adNOpV`
ya, you can give background image of the specific color and place it on that specific region
css
.container-fluid{
background:url( //image link// );
background-position: // arrange image // ;
background-size: auto 100%;
}
I have a strange issue happening on a website I'm developing, when viewed in Firefox. I'm using relatively-positioned image links within an absolutely-positioned container.
The positioning and links work fine, but when I inspect in Firebug, I get these "ghost" links that appear in the locations where the images would have appeared had they not been re-positioned... if that makes any sense:
HTML:
<div id="container">
<div id="logo">
<img src="Button1.png" alt="Soundcloud" title="Soundcloud" class="button" id="soundcloud-button" />
<img src="Button1.png" alt="Videos" title="Videos" class="button" id="videos-button" />
</div> <!-- /logo -->
</div> <!-- /container -->
CSS:
#container {
position: absolute;
top: 50%;
margin-top: -85px;
left: 0;
width: 100%;
}
#logo {
background-image: url('logo1.png');
width: 393px;
height: 170px;
margin: 0 auto;
}
.button { width: 53px; height: 53px; position: relative; }
#soundcloud-button { top: 105px; left: 115px; }
#videos-button { top: 33px; left: 147px; }
Does anyone know what is causing this? Is it a problem with positioning, or whitespace, or something else?
You have the same in chrome.
To fix this apply your css to the <a> tag, not <img> inside <a>. Make 2 classes to adjust their position, .circle1 and .circle2, for example.
<div id="container">
<div id="logo">
<a href="https://soundcloud.com/haelu" class="circle1">
<img src="Button1.png" alt="Soundcloud" title="Soundcloud"/>
</a>
<a href="/videos.html" class="circle2">
<img src="Button1.png" alt="Videos" title="Videos" />
</a>
</div> <!-- /logo -->
</div> <!-- /container -->
#logo a {
position: relative;
display: inline-block;
width: 53px;
height: 53px;
}
#logo .circle1 {
top: 105px;
left: 115px;
}
#logo .circle2{
top: 33px;
left: 147px;
}
Look at the screenshot how it works: