How to customise an image with css on a react-app application? - html

I'm currently working on a website for a client, but I'm struggling on making an image grid like this:
example
However, the hardest parts for me to achieve are: Set a grid of 4 images, responsive, where I can move the border below the image.
I've tried to set each of the images inside a div tag which I give it a border. Since I'm pretty much new into coding, I'm not sure what else should I try.
div.composition {
display: inline-block;
float: right;
position: relative;
}
img.composition-photo {
background-position: center center;
background-repeat: no-repeat;
margin: 0 auto;
object-fit: cover;
width: 250px;
height: 250px;
position: absolute;
}
<div className="composition">
<div>
<img src={ModelOne} alt="Modelo 1" className="composition-photo img-fluid" />
</div>
<div>
<img src={ModelTwo} alt="Modelo 2" className="composition-photo img-fluid" />
</div>
<div>
<img src={ModelThree} alt="Modelo 3" className="composition-photo img-fluid" />
</div>
<div>
<img src={ModelFour} alt="Modelo 4" className="composition-photo img-fluid" />
</div>
</div>
Thanks in advance for your valuable help!

Maybe not the best way, but one of the ways would be this. I hope it helps.
.composition {
position: relative;
float: right;
}
.composition-photo {
background-position: center center;
background-repeat: no-repeat;
margin: 0 auto;
object-fit: cover;
width: 250px;
height: 250px;
}
.composition img:nth-child(1){
position: absolute;
top: 10px;
right: 265px;
}
.composition img:nth-child(2){
position: absolute;
top: 0;
right: 0;
}
.composition img:nth-child(3){
position: absolute;
top: 280px;
right: 280px
}
.composition img:nth-child(4){
position: absolute;
top: 260px;
right: 15px;
}
<div class="composition">
<img src='https://guianoivaonline.com.br/wp-content/uploads/terno-para-noivo-18-700x467.jpg' alt="Modelo 1" class="composition-photo"/>
<img src='https://guianoivaonline.com.br/wp-content/uploads/terno-para-noivo-18-700x467.jpg' alt="Modelo 2" class="composition-photo"/>
<img src='https://guianoivaonline.com.br/wp-content/uploads/terno-para-noivo-18-700x467.jpg' alt="Modelo 3" class="composition-photo"/>
<img src='https://guianoivaonline.com.br/wp-content/uploads/terno-para-noivo-18-700x467.jpg' alt="Modelo 4" class="composition-photo"/>
</div>

Related

My png files aren't showing on my website

My ribbon.png and logo.png both have a broken icon on my webpage while my fade.png is perfect. I have them with the correct path so I'm kind of stumped. I should say as well that the difference in the 3 is that those 2 up there I deleted the background so that only the ribbon and logo show and the back is transparent not sure if I need to add special code for that. I'm seriously out of html practice so anyone have a tip?
html
<img src="ribbon.PNG" alt="Ribbon Picture" width="270" height="573" class="ribbon" style="height:auto " >
<img class="logo" src="logo.PNG" alt="Logo" style="height:auto " />
css
div.fade{
position: relative;
z-index: 1;
height: 1400px;
width: auto;
top: 200px;
background-image: url("fade.png");
background-repeat: repeat-x;
}
img.ribbon{
position: absolute;
top: 600px;
left: 20px;
width: 229px;
}
img.facebook{
position:absolute;
top: 418px;
left: 940px;
}
img.logo{
position: absolute;
top:20px;
left: 250px;

Materialize image over another

So I'm having this fiddle
I am trying too keep the profile picture in middle, even when screen width gets small.
The problem is with my position:absolute so margins:auto won't work.
Instead I used :left:40%.
Any ideas?
to center horizontally and vertically, using your code, you have to set
position:absolute + top/right/bottom/left:0 + margin:auto in img
#profile-page-header .card-image {
height: 225px;
}
#profile-page-header .card-profile-image img {
width: 110px;
position: absolute;
z-index: 1;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css" rel="stylesheet" />
<div class="row">
<div class="col s12 m8">
<div id="profile-page-header" class="card">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="http://static.vecteezy.com/system/resources/previews/000/094/491/original/polygonal-texture-background-vector.jpg" alt="user background">
</div>
<figure class="card-profile-image">
<img src="http://zblogged.com/wp-content/uploads/2015/11/21.jpg" alt="profile image" class="circle z-depth-2 responsive-img activator">
</figure>
<div class="card-content">
<div class="row">
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</div>
</div>
</div>
</div>
</div>
you need to use left:50%; then use margin-left:-55px; the margin left is 55 because your width is 110 so it is half of width.
#profile-page-header .card-profile-image {
width: 110px;
position: absolute;
top: 190px;
z-index: 1;
left: 50%;
cursor: pointer;
margin-left: -55px;
}
https://jsfiddle.net/IA7medd/eL01jjf9/2/
You can wrap the actual image within a container div with position: absolute. As the parent container is now absolutely positioned, .card-profile-image can now use margin: auto.
https://jsfiddle.net/eL01jjf9/5/
#profile-page-header .card-profile-image-container {
width: 100%;
position: absolute;
top: 190px;
z-index: 1;
}
#profile-page-header .card-profile-image {
width: 110px;
cursor: pointer;
margin: auto;
}
`
<div class="card-profile-image-container">
<figure class="card-profile-image">
<img src="http://zblogged.com/wp-content/uploads/2015/11/21.jpg" alt="profile image" class="circle z-depth-2 responsive-img activator">
</figure>
</div>

Absolute position: I can't put my text at the bottom of my CSS3 slideshow

I know that it is possible to put a text at the bottom of a block by using the absolute position and adding "bottom: 0;", but impossible for me. I try for a long time, but I can't. I am currently working on a slideshow in CSS3 and I grouped my 4 pictures in absolute position.
Here is my HTML code:
<h1 id="welcome-to">Welcome to! Web site for highly customized styles for the XenForo forum software.</h1>
<h1 id="all-available-styles">All available styles</h1>
<div id="slideshow">
<div id="slideshow-container">
<div class="slideshow-content">
<img src="images/image-1.jpg" alt="Image 1">
<span>First Image</span>
</div>
<div class="slideshow-content">
<img src="images/image-2.jpg" alt="Image 2">
<span>Second Image</span>
</div>
<div class="slideshow-content">
<img src="images/image-3.jpg" alt="Image 3">
<span>Third Image</span>
</div>
<div class="slideshow-content">
<img src="images/image-4.jpg" alt="Image 4">
<span>Fourth Image</span>
</div>
</div>
</div>
and my slideshow CSS code:
#slideshow
{
text-align: center;
height: 440px;
}
#slideshow #slideshow-container
{
position: relative;
}
#slideshow #slideshow-container img
{
position: absolute;
right: 0;
left: 0;
margin: 0 auto;
pointer-events: none;
}
#slideshow #slideshow-container span
{
position: absolute;
right: 0;
left: 0;
font-size: 15px;
}
I use a span to surround my text and adding "bottom: 0;" to:
#slideshow #slideshow-container span
{
position: absolute;
right: 0;
left: 0;
bottom: 0;
font-size: 15px;
}
The text remains attached to the top: http://i.stack.imgur.com/SyzTL.png
How can I do, please?
this will work for you i think.
#slideshow #slideshow-container {
position: static;
}

Adding image over another image - bootstrap

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/

CSS overlay on images

I want to simply overlay these 4 images with a block of colour, and text aligned in the middle of each. But with my current use of "position: absolute" to get each image in the correct position and z-index etc. I'm finding it hard to attempt something like this: http://jsfiddle.net/jimjeffers/mG78d/1/ and get it to work. My position absolute seems to always break other code I've been trying from stackoverflow and others, even tried a few jquery scripts.
Live URL: http://bit.ly/1k7RgDS
HTML
<div class="index-gallery">
<img src="<?php HTTP_HOST ?>/Images/1.JPG" alt="" class="img1" />
<img src="<?php HTTP_HOST ?>/Images/2.JPG" alt="" class="img2" />
<!-- <img src="<?php //HTTP_HOST ?>/Images/3.JPG" alt="" class="img3" /> -->
<img src="<?php HTTP_HOST ?>/Images/6.JPG" alt="" class="img3" />
<img src="<?php HTTP_HOST ?>/Images/5.JPG" alt="" class="img4" />
</div>
CSS
#index-gallery .index-gallery { margin-bottom: 30px; }
#index-gallery .index-gallery img:hover { opacity:0.6; filter:alpha(opacity=40); /* For IE8 and earlier */ }
#index-gallery .index-gallery img:before { content: "Show Home Hemel Hempstead"; }
#index-gallery .index-gallery .img1 { width: 550px; top: 10px; position: absolute; z-index: 3; display: block; }
#index-gallery .index-gallery .img2 { width: 550px; right: 0; position: absolute; z-index: 2; display: block; }
#index-gallery .index-gallery .img3 { width: 400px; top: 400px; left: 10px; position: absolute; z-index: 4; display: block; }
#index-gallery .index-gallery .img4 { width: 710px; top: 400px; right: 0; position: absolute; z-index: 1; display: block; }
I've got a little bit of a transparency code to work but looking more for what's on that JSFIDDLE with the ability to center the text in the middle when hovered over with colour overlay. If you have a suggestion which would change all the code I don't mind, if this is bad practice what i've got so far.
So - Working with what you already have you could just try this route. Minimal position changes and I've added Paragraph tags inside your spans so you can position the text absolutely.
http://jsfiddle.net/9H7eM/
<span><p>Hello</p></span>
#overlay {position: relative;}
#overlay span {
background: red;
bottom: 0;
display: block;
left: 0;
opacity: 0;
position: absolute;
right: 0;
top: 0;
z-index: 1;
}
#overlay span p {
position: absolute;
text-align: center;
width: 100px;
top: 30px;
font: bold 16px arial;
}
IF you're open to changing your code, you could try an approach similar to this: http://jsfiddle.net/te6t8/1/
But if you're already happy with how it is, stick with what you have and know!