Using separate id HTML - html

I have an image in HTML (aaa.jpg) and when I hover I need it to switch to another image (t1.jpg) indicated in css
.single-member .thumb .overlay-member #1 {
background: url(../img/t1.jpg) no-repeat center center/cover;
text-align: center;
padding: 30px;
opacity: 0;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
<div class="row">
<div class="col-lg-3 col-sm-6">
<div class="single-member">
<div id="1">
<div class="thumb relative" style="background: url(img/aaa.jpg);">
<div class="overlay overlay-member d-flex flex-column justify-content-end align-items-center">
<div class="line"></div>
<div class="social d-flex align-items-center justify-content-center">
<i class="fa fa-linkedin"></i>
</div>
</div>
</div>
</div>
<div class="desc text-center">
<h5 class="text-uppercase">XXX</h5>
<p>ZZZ</p>
</div>
</div>
</div>
The above code works fine, but it works for using the same image for all. I need to use different images for people, so I repeated the code in html and css but changing the id. Then it is showing only the image stated in HTML file, flipping to the css ones.

.card {
width: 130px;
height: 195px;
position: relative;
display: inline-block;
margin: 50px;
}
.card .img-top {
display: none;
position: absolute;
top: 0;
left: 0;
z-index: 99;
}
.card:hover .img-top {
display: inline;
}
<div class="card">
<img src="https://www.tutorialrepublic.com/examples/images/card-front.jpg" alt="Card Back">
<img src="https://www.tutorialrepublic.com/examples/images/card-back.jpg" class="img-top" alt="Card Front">
</div>

First of all you needs to make some changes in your HTML
You can't use number ID as a css selector like #1 have to replaced with #one
REF: #1 should not use
and you can simply change image by css :hover selector.
Hope this will help you.
.single-member #one {
background: url(https://via.placeholder.com/728x90.png?text=normal) no-repeat center center/cover;
text-align: center;
padding: 30px;
opacity: 1;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
.single-member #one:hover {
background: url(https://via.placeholder.com/728x90.png?text=hover) no-repeat center center/cover;
}
<div class="row">
<div class="col-lg-3 col-sm-6">
<div class="single-member">
<div id="one">
<div class="thumb relative">
<div class="overlay overlay-member d-flex flex-column justify-content-end align-items-center">
<div class="line"></div>
<div class="social d-flex align-items-center justify-content-center">
<i class="fa fa-linkedin"></i>
</div>
</div>
</div>
</div>
<div class="desc text-center">
<h5 class="text-uppercase">XXX</h5>
<p>ZZZ</p>
</div>
</div>
</div>

I suggest to use Jscript in HTML it will be of one line
<img src='FirstImage.png' onmouseover="this.src='ChangedImage.png';" onmouseout="this.src='FirstImage.png';" />

Related

How to make responsive the page content when sidebar toggled?

I'm creating a webpage with a sidebar left. And Bootstrap 4 fixed size cards in the page content.
When it is toggled at view-port size - >768px to 100's of pixels, the page content is not act as responsively (overlapped and compressed all).
Why? look #media(min-width:768px){...}.
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
body {
overflow-x: hidden;
}
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled {
padding-left: 250px;
}
#sidebar-wrapper {
z-index: 1000;
position: fixed;
width: 0;
height: 100%;
overflow-y: auto;
background: #000;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.sidebar {
left: 250px;
margin-left: -250px;
}
#wrapper.toggled .sidebar {
width: 250px;
}
#page-content-wrapper {
width: 100%;
position: absolute;
}
#wrapper.toggled #page-content-wrapper {
margin-right: -250px;
}
#media(min-width:768px) {
#wrapper {
padding-left: 250px;
}
#wrapper.toggled {
padding-left: 0;
}
#wrapper .sidebar {
width: 250px;
}
#wrapper.toggled .sidebar {
width: 0;
}
#page-content-wrapper {
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right: 0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div id="wrapper">
<div id="sidebar-wrapper" class="sidebar">
<ul>
<li>Dashboard</li>
</ul>
</div>
<div id="page-content-wrapper">
<div class="container-fluid">
<h1>Simple Sidebar</h1>
<a class="btn btn-secondary" href="#menu-toggle-left" id="menu-toggle">Toggle Left</a>
<div class="row">
<div class="col-6 col-sm-4 col-md-3 col-lg-2 mb-4">
<div class="card bg-primary" style="width:10rem;height:10rem;">
<div class="card-header">
<div class="card-title">Title 1</div>
</div>
<div class="card-body text-center">
<p>This is a paragraph</p>
</div>
</div>
</div>
<div class="col-6 col-sm-4 col-md-3 col-lg-2 mb-4">
<div class="card bg-primary" style="width:10rem;height:10rem;">
<div class="card-header">
<div class="card-title">Title 2</div>
</div>
<div class="card-body text-center">
<p>This is a paragraph</p>
</div>
</div>
</div>
<div class="col-6 col-sm-4 col-md-3 col-lg-2 mb-4">
<div class="card bg-primary" style="width:10rem;height:10rem;">
<div class="card-header">
<div class="card-title">Title 3</div>
</div>
<div class="card-body text-center">
<p>This is a paragraph</p>
</div>
</div>
</div>
<div class="col-6 col-sm-4 col-md-3 col-lg-2 mb-4">
<div class="card bg-primary" style="width:10rem;height:10rem;">
<div class="card-header">
<div class="card-title">Title 4</div>
</div>
<div class="card-body text-center">
<p>This is a paragraph</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
How to correct it? Thanks.
Here's a simple solution, add style="width:100vw;" to <div class="row"></div>
<div id="wrapper">
<div id="sidebar-wrapper" class="sidebar">
...
</div>
<div id="page-content-wrapper">
<div class="container-fluid">
...
<div class="row" style="width:100vw;">
...
</div>
</div>
</div>

Issue with <p></p> in Bootstrap 4, HTML, and CSS

I try to have multiple p tags in a division, but the paragraphs aren't separating and are just bunching together. The applicable code is as follows:
<div class="row">
<div class="col-md-12 d-flex justify-content-center padding-top">
<p>IMPORTANT LEGAL DISCLAIMER FOR TESTIMONIALS, RISK AND TYPICAL RESULTS, AS WELL AS REFUNDS</p>
<p>Test</p>
</div>
</div>
and the link to codeply is https://www.codeply.com/go/cJ37oz9g4Q. If you go to codeply, then you'll see that "Test" appears immediately after the word "REFUNDS". I have tried modifying the code, looking for known issues, etc.
How can I fix this?
You need to remove d-flex class from this code:
<div class="col-md-12 justify-content-center padding-top">
<p>IMPORTANT LEGAL DISCLAIMER FOR TESTIMONIALS, RISK AND TYPICAL RESULTS, AS WELL AS REFUNDS</p>
<p>Test</p>
</div>
This is because of d-flex class - it forces <p> to become flex-items and by default they align themself along horizontal axis. Replace d-flex and justify-content-center with text-center
.social {
margin: 0;
padding: 0;
}
.social ul {
margin: 0;
padding: 5px;
}
.social ul li {
margin: 5px;
list-style: none outside none;
display: inline-block;
}
.social i {
width: 40px;
height: 40px;
color: #FFF;
background-color: #909AA0;
font-size: 22px;
text-align:center;
padding-top: 12px;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
-o-border-radius: 50%;
transition: all ease 0.3s;
-moz-transition: all ease 0.3s;
-webkit-transition: all ease 0.3s;
-o-transition: all ease 0.3s;
-ms-transition: all ease 0.3s;
}
.social i:hover {
color: #FFF;
text-decoration: none;
transition: all ease 0.3s;
-moz-transition: all ease 0.3s;
-webkit-transition: all ease 0.3s;
-o-transition: all ease 0.3s;
-ms-transition: all ease 0.3s;
}
.social .fa-facebook:hover {
background: #4060A5;
}
.social .fa-twitter:hover {
background: #00ABE3;
}
.social .fa-instagram:hover {
background: #375989;
}
.social .fa-youtube:hover {
background: #FF1F25;
}
.social .fa-youtube-play:hover {
background: #DF192A;
}
p {
color: #FFF;
}
.paddding-top {
padding-bottom: 15px;
padding-top: 18px;
border-bottom: 1px solid white;
}
/*this is the padding for the form from the top*/
.padding-form-top{
padding-top: 18px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<footer class="bg-inverse">
<div class="row">
<div class="col-md-12 d-flex justify-content-center">
<div class="social">
<ul>
<li><i class="fa fa-lg fa-instagram"></i></li>
<li><i class="fa fa-lg fa-facebook"></i></li>
<li><i class="fa fa-lg fa-twitter"></i></li>
<li><i class="fa fa-lg fa-youtube"></i></li>
</ul>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12 text-center padding-top">
<p>IMPORTANT LEGAL DISCLAIMER FOR TESTIMONIALS, RISK AND TYPICAL RESULTS, AS WELL AS REFUNDS</p>
<p>Test</p>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-12 d-flex justify-content-center">
<div class="col-md-4 col-md-offset-4 text-center padding-form-top">
<form class="form-width">
<div class="form-group">
<input type="email" class="form-control" id="email" placeholder="Your Email Address">
</div>
<button type="submit" class="btn btn-success">Sign Up for the Latest Updates</button>
</form>
</div>
</div>
</div>
</footer>

Bootstrap divs not stacking right

I have two divs with .container class which are not stacking properly. Instead, they overlap.
This is my code:
HTML
<div id="crossfadingImages" class="container">
<img src="./media/..." class="bottom img-responsive" alt="..."/>
<img src="./media/..." class="top img-responsive" alt="..."/>
</div>
<div id="about" class="container">
<div class="row">
<div class="col-sm-6">
<p>about...</p>
</div>
<div class="col-sm-6">
</div>
</div>
</div>
CSS
#crossfadingImages{
position: relative;
width: 100%;
padding: 0;
margin-top: 55px;
}
#crossfadingImages img{
position: absolute;
left: 0;
-webkit-transition: opacity 3s ease-in-out;
-moz-transition: opacity 3s ease-in-out;
-o-transition: opacity 3s ease-in-out;
transition: opacity 3s ease-in-out;
}
#crossfadingImages img.top:hover{
opacity: 0;
}
I think the problem is absolute position of images in crossfadingImages div.
Please provide your solution to my problem as well as an explanation.
Then you can you the hover() function
$(document).ready(function() {
$('#crossfadingImages img').hover(function() {
$('#crossfadingImages img:first-child').stop().fadeOut(500);
$('#crossfadingImages img:last-child').stop().fadeIn(500);
},
function() {
$('#crossfadingImages img:first-child').stop().fadeIn(500);
$('#crossfadingImages img:last-child').stop().fadeOut(500);
});
});
#crossfadingImages {
width: 100%;
padding: 0;
margin-top: 55px;
top: 0;
display: block;
}
#crossfadingImages img {
position: absolute;
width: 45%;
left: 0;
}
#crossfadingImages img:last-child {
display: none;
}
#about{
position:relative;
top:80px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div id="crossfadingImages" class="container">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="bottom img-responsive" alt="..." />
<img src="https://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png" class="top img-responsive" alt="..." />
</div>
<div id="about" class="container">
<div class="row">
<div class="col-sm-6">
<p>about...</p>
</div>
<div class="col-sm-6">
</div>
</div>
</div>
Ok, I managed to solve this problem by using only CSS.
NOTE: This will only work if you have two images (JPG or JPEG format) of the same size. If they aren't the same size then the bottom image will be shown all the time cause we are just changing opacity of top image.
#crossfadingImages{
position: relative;
width: 100%;
padding: 0;
margin-top: 55px;
}
#crossfadingImages img{
left: 0;
width: 45%;
-webkit-transition: opacity 3s ease-in-out;
-moz-transition: opacity 3s ease-in-out;
-o-transition: opacity 3s ease-in-out;
transition: opacity 3s ease-in-out;
}
#crossfadingImages img.top:hover{
opacity: 0;
}
.bottom-image{
position: absolute;
}
.top-image{
position: relative;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div id="crossfadingImages" class="container">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="bottom img-responsive bottom-image" alt="..."/>
<img src="https://upload.wikimedia.org/wikipedia/commons/4/4a/Logo_2013_Google.png" class="top img-responsive top-image" alt="..."/>
</div>
<div id="about" class="container">
<div class="row">
<div class="col-sm-6">
<p>about...</p>
</div>
<div class="col-sm-6">
</div>
</div>
</div>

Bootstrap Gallery Hover

I have built a hover effect for my gallery. The gallery is within a Bootstrap Grid.
The hover itself works fine, but in some screen sizes the overlay goes over the gallery images.
Has anybody an idea or a solution or a hint for this problem?
Here an example:
demo
HTML:
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
</div>
</div>
CSS:
.box {
position: relative;
cursor: pointer;
width: 100%;
min-height: 100%;
overflow: hidden;
margin-bottom: 30px;
}
.box .overbox {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 100;
background-color: rgba(204, 36, 42, 0.75);
color: #fff;
opacity: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.box:hover .overbox {
opacity: 1;
}
.box .title {
font-size: 22px;
line-height: 131%;
font-weight: 400;
text-align: center;
padding-top: 95px;
}
#media (max-width: 991px) {
.box .title {
padding-top: 43px;
}
}
.box .tagline {
position: absolute;
bottom: 0px;
padding-top: 16px;
padding-bottom: 16px;
width: 100%;
display: flex;
justify-content: center;
font-size: 16px;
font-weight: 400;
font-style: italic;
border-top: 1px solid rgb(255, 255, 255);
}
.box_client {
position: relative;
width: 100%;
height: 100%;
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.box_client:hover {
background: rgb(235, 234, 233);
-webkit-filter: grayscale(0%);
-moz-filter: grayscale(0%);
-ms-filter: grayscale(0%);
-o-filter: grayscale(0%);
filter: grayscale(0%);
}
.img-responsive {
margin: 0 auto;
}
the overlay goes over the gallery images because you overlay has width:100%; and when the image is smaller than the width of its container the overlay goes over the gallery image because of the width of image
you have 2 options you can make the image width:100% or you can change the style of .box class and remove width:100%; and make its display:inline-block;
.box {
position: relative;
cursor: pointer;
// width: 100%; // remove this
display:inline-block; // add this
min-height: 100%;
overflow: hidden;
margin-bottom: 30px;
}
The Bootstrap column is growing and shrinking while the image has the same fixed size. So .responsive-image is smaller than its parent div. There are a few solutions:
1) Remove the image in the html and have it as a background-image
.box {
background: url(image-url) cover no-repeat;
}
2) Make the image 100% width
.response-image {
width: 100%;
}
3) Or as Ahmed Salama suggests, remove the width: 100% and add display: inline-block;
Your placeholder is smaller then the parent div element, which fits into the whole witdh of it's parent. Thats caused by the class img-responsive, that itself fits the the image to "max-width: 100%". You should use a bigger image or fit it to the size to your parent box, what is not recommended.
In this pen, i changed the placeholdersizes to 767px x 767px: http://codepen.io/pure180/details/OXpNxM/
HTML:
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/767x767" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/767x767" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/767x767" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
</div>
</div>
I fixed with this
.box {
position: relative;
cursor: pointer;
max-width: 300px;
min-height: 100%;
overflow: hidden;
margin: 0 auto;
margin-bottom: 30px;}
Here's my approach: https://jsfiddle.net/5f285ask/3/
.box {
position: relative;
display: inline-block;
}
.box .overbox {
background-color: rgba(204, 36, 42, 0.75);
height: 100%;
left: 0;
opacity: 0;
position: absolute;
top: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
width: 100%;
}
.box:hover .overbox {
opacity: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-4 col-sm-4">
<div class="box">
<a href="#">
<img alt="" src="http://placehold.it/300x300" class="img-responsive">
<div class="overbox">
overbox content
</div>
</a>
</div>
</div>

Translate with CSS to the top of a div

I have 3 boxes within a fluid container.
Each box has a heading title, an icon and some text below.
On :hover I want the icon to move to the top of the <div> and change it's size, I have managed to "achieve" it but using certain number of pixels.
That will not work in mobile resolutions if the title text is longer and takes 2 lines.
Here is what I have done so far:
Fiddle here
HTML
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 text-center market-blocks orange wow rollIn">
<div class="service-box">
<h2>Title</h2>
<i class="fa fa-5x fa-paper-plane wow bounceIn market-icon" data-wow-delay=".1s"></i>
<p class="">Certain text below the icon</p>
</div>
</div>
</div>
CSS
.container{
text-align:center;
}
.market-blocks{
background: #3aa0d1;
padding: 30px 0 30px 0;
cursor:pointer;
}
.orange{
background: #e97d68;
}
i.market-icon {
-webkit-transition: 1s ease-in;
-moz-transition: 1s ease-in;
-o-transition: 1s ease-in;
transition: 1s ease-in
}
.market-blocks:hover i.market-icon {
-webkit-transform: translate(0,-70px);
-moz-transform: translate(0,-70px);
-o-transform: translate(0,-70px);
-ms-transform: translate(0,-70px);
transform: translate(0,-70px);
font-size: 1.8em;
}
How can I do it? And also is there a better way to do the movement from the initial position to the top of the <div>?
Pure HTML/CSS solution:
.container {
text-align: center;
}
.market-blocks {
background: #3aa0d1;
padding: 30px 0;
cursor: pointer;
}
.orange {
background: #e97d68;
}
.service-box {
display: inline-block;
}
.service-box-header {
position: relative;
}
.market-title {
padding-bottom: 5em;
-webkit-transition: 1s ease-in;
transition: 1s ease-in
}
.market-icon {
position: absolute;
right: 0;
bottom: 0;
left: 0;
-webkit-transition: 1s ease-in;
transition: 1s ease-in
}
.market-blocks:hover .market-title {
padding-bottom: 0;
}
.market-blocks:hover .market-icon {
bottom: 100%;
font-size: 1.8em;
}
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12 text-center market-blocks orange wow rollIn">
<div class="service-box">
<div class="service-box-header">
<h2 class="market-title">Very-very-very-very-very-very-very-very loooooooooooooooooooong title</h2>
<i class="fa fa-5x fa-paper-plane wow bounceIn market-icon"></i>
</div>
<p class="">Certain text below the icon</p>
</div>
</div>
</div>
</div>