Text overriding the border? - html

I am trying to have this sort of this effect. I created an image wrapper and then I created a price tag div which is a child of it. I have set the border-left and border-bottom to a certain amount pixels and then I changed the border-left color to transparent. It creates a triangle similar to above, but when I write something inside the price tag div it just overwrites its part.
#accomodation {
min-height: 1000px;
text-align: center;
padding-top: 100px;
}
#accomodation .head-text {
font-size: 40px;
}
#accomodation .hotel-card .image-wrapper {
width: 100%;
/* overflow: hidden; */
position: relative;
}
#accomodation .hotel-card .image-wrapper img {
width: 100%;
}
#accomodation .hotel-card .image-wrapper .price-tag {
position: absolute;
bottom: 0px;
right: 0;
border-left: 150px solid transparent;
border-bottom: 150px solid #d46e4e;
z-index: 90;
opacity: 0.7;
transition: 0.2s;
color: red;
font-size: 30px;
}
#accomodation .hotel-card .image-wrapper:hover .price-tag {
transform: scale(1.1);
transform-origin: bottom right;
}
<section id="accomodation">
<h3 class="head-text">
Luxury Accomodation
</h3>
<p class="caption-text text-muted">
Duis metus sem, aliquet vitae mi eget, vehicula vehicula enim. In consectetur velit <br> lectus sollicitudin.
</p>
<div class="container mt-5">
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="hotel-card">
<div class="image-wrapper">
<img src="../../photos/hotels/1-accomodation.jpg" alt="">
<div class="price-tag">
<span>900</span>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

If you just want to nest the price tag in the triange:
..
<div class="price-tag">
<span class="price-val">900</span>
</div>
..
.price-tag .price-val {
position: relative;
top: 100px;
}

You should try using transform: rotate() property to get the desired result. Try this code.
#accomodation {
min-height: 1000px;
text-align: center;
padding-top: 100px;
}
#accomodation .head-text {
font-size: 40px;
}
#accomodation .hotel-card .image-wrapper {
width: 100%;
position: relative;
overflow: hidden;
}
#accomodation .hotel-card .image-wrapper img {
width: 100%;
display: block;
}
#accomodation .hotel-card .image-wrapper .price-tag {
position: absolute;
bottom: -100px;
right: -100px;
z-index: 90;
opacity: 0.7;
transition: 0.2s;
color: red;
font-size: 30px;
height: 200px;
width: 200px;
transform: rotate(-45deg);
background: #d46e4e;
}
#accomodation .hotel-card .image-wrapper .price-tag span {
transform: rotate(45deg);
display: inline-block;
margin: 20px;
}
#accomodation .hotel-card .image-wrapper:hover .price-tag {
transform: scale(1.1) rotate(-45deg);
}

Related

CSS Image Hover Effect?

I want my image hovers to look like this,
but For some reason, my CSS styling is not working. You may notice the #content in each of the CSS styling options. That is because I only wanted these styles to apply to a certain section of my website. I looked online and used the W3Schools resource, yet for some reason, it still doesn’t work. My images do not have the hover effect.
#content.container {
position: relative;
width: 50%;
}
#content img {
width: 100%;
height: auto;
border-radius: 50%;
}
#content .column {
float: left;
width: 33.33%;
padding: 5px;
}
#content .row::after {
content: "";
clear: both;
display: table;
}
#content .overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: #008CBA;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
border-radius: 50%;
}
#content .img:hover .overlay {
bottom: 0;
height: 100%;
opacity: 0.5;
}
#content.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<div class="container">
<div class="column">
<div class="team">
<div class="img">
<img src="/static/img/team/team-1.jpg" alt="" style="width: 200px;">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<h3 class="team-prof">
Dr. Pawan Kumar Kesari
</h3>
</div>
</div>
</div>
It seems you haven't followed THIS guide very well.
You also have not identified what #content is.
You need to revise how you target IDs, Classes and Elements in CSS.
Here is your code remodified to follow the guide, plus I added in #content for you.
#content .img {
position: relative;
width: 50%;
}
#content img {
display: block;
width: 200px;
height: auto;
border-radius: 50%;
}
#content .overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 200px;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
border-radius: 50%;
}
#content .img:hover .overlay {
opacity: 1;
}
#content .text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<div id="content">
<div class="container">
<div class="column">
<div class="team">
<div class="img">
<img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<h3 class="team-prof">
Dr. Pawan Kumar Kesari
</h3>
</div>
</div>
</div>
</div>
There were flaws in your code. There was no shared container. There were no spaces in the css rules between the identifier and the classes. #content .overlay had a height: 0 - this makes the object invisible. My answer isn't perfect, but I've tidied up the code a bit.
.main {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
}
.main_content {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
width: 1000px;
}
.main_content_box {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
}
.main_content_box_image {
position: relative;
}
.main_content_box:hover > .main_content_box_image p {
display: flex;
}
.main_content_box:hover > .main_content_box_image img {
filter: brightness(25%);
}
.main_content_box:hover a {
color: #337ab7;
}
.main_content_box_image img {
width: 250px;
height: 250px;
border-radius: 125px; /* or 50%*/
transition: .5s;
}
.main_content_box_image p {
display: none;
position: absolute;
top: 40%;
left: 20%;
right: 0;
font-size: 14px;
color: #fff;
}
.main_content_box a {
color: #333;
font-size: 16px;
font-weight: bold;
text-decoration: none;
margin: 20px 0 0 0;
}
<div class="main">
<div class="main_content">
<div class="main_content_box">
<div class="main_content_box_image">
<img src="https://icdn.lenta.ru/images/2019/11/01/13/20191101130724350/pwa_vertical_1024_f1555b2890fcb39f7ecc85cf65e73fc5.png" alt="">
<p>MBBS, General Physician</p>
</div>
Dr. Pawan Kumar Kesari
</div>
<div class="main_content_box">
<div class="main_content_box_image">
<img src="https://icdn.lenta.ru/images/2019/11/01/13/20191101130724350/pwa_vertical_1024_f1555b2890fcb39f7ecc85cf65e73fc5.png" alt="">
<p>MBBS MD(Medicine) General Physician</p>
</div>
Dr. Nitin Kumar Srivastava
</div>
<div class="main_content_box">
<div class="main_content_box_image">
<img src="https://icdn.lenta.ru/images/2019/11/01/13/20191101130724350/pwa_vertical_1024_f1555b2890fcb39f7ecc85cf65e73fc5.png" alt="">
<p>MBBS General Consultant and Diabetician</p>
</div>
Dr. (Mrs) Halima
</div>
</div>
</div>

Align Images Side By Side with hover

<div align="center">
<div class="container2">
<img src="img/3.png" alt="discussion Threads" class="image" height="200px" width="150px">
<div class="overlay">
<div class="text">Here you can discuss different topics and ask or answer questions.</div>
</div>
</div>
<div class="container2">
<img src="download.png" alt="Avatar" class="image">
<div class="overlay overlay2">
<div class="text">Bottom</div>
</div>
</div>
<div class="container2">
<img src="download.png" alt="Avatar" class="image">
<div class="overlay overlay3">
<div class="text">Bottom</div>
</div>
</div>
</div>
i want to make the images next to each other but i can't idk why or how tbh and this is the css i have tried everything it doesn't work
I want 3 images side by side with hover and caption, at the moment I have 3 images going from top to bottom, the hover is good but not side by side. How do I make the images appear side by side? Thanks.
.container2 {
position: relative;
width: 250px;
}
.image {
display: block;
width: 250px;
height: 300px;
height: auto;
margin: 17%;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay {
height: 85%;
}
.text {
color: white;
font-size: 15px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.overlay2 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay2 {
height: 85%;
}
.overlay3 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay3 {
height: 85%;
}
You would have to add float property to your container2 selector. Please check the css rule below.
.container2 {
float: left;
position: relative;
width: 250px;
}
.container {
width: 400px;
height: 400px;
padding: 0px;
display: grid;
grid-template-columns: auto auto auto;
}
.item {
width: 100px;
height: 200px;
margin: 2px;
}
<div class="container">
<div class="item" style="background-color:red">
</div>
<div class="item" style="background-color:blue">
</div>
<div class="item" style="background-color:yellow">
</div>
</div>
Why don't you grid-display property ?
This might help you
For these such scenarios there is a beautiful/clean/simple concept called flex which is helping by decreasing number of lines of code:
here is the example with column, color and hover effect, hope it helps you:
#MainDiv {
height: 200px;
width: 650px;
display: flex;
/* here is a concept */
flex-direction: row;
/* you can either change it to row/columns */
padding: 5px;
}
#firstDiv {
width: 200px;
margin: 5px;
background-color: red;
}
#secondDiv {
width: 200px;
margin: 5px;
background-color: blue;
}
#thirdDiv {
width: 200px;
margin: 5px;
background-color: green;
}
#firstDiv:hover {
background-color: blue;
color: white;
}
#secondDiv:hover {
background-color: green;
color: white;
}
#thirdDiv:hover {
background-color: red;
color: white;
}
<div id="MainDiv">
<div id="firstDiv">First Div</div>
<div id="secondDiv">Second Div</div>
<div id="thirdDiv">Third Div</div>
</div>

hover effect works on two elements, but it should only work on only element

I am learning CSS. I get one problem. hover effect should work when the mouse hovers on the box element. when the mouse doesn't hover on the box element, the content element is under box element and should be hidden. now I put mouse under box element (content element), hover effect still works. Why it is like that? and any solution based on my code?
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.container {
width: 1200px;
height: 300px;
margin: 240px auto;
position: relative;
}
.container .box {
position: relative;
width: calc(400px - 30px);
height: calc(300px - 30px);
background-color: #000;
float: left;
margin: 15px;
box-sizing: border-box;
border-radius: 10px
}
.container .box .icon {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #f00;
transition: 0.5s;
z-index: 1;
}
.container .box:hover .icon {
top: 20px;
left: calc(50% - 40px);
width: 80px;
height: 80px;
border-radius: 50%;
}
.container .box .icon .fas {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 80px;
color: #fff;
transition: 0.5s;
}
.container .box:hover .icon .fas {
font-size: 40px
}
.container .box .content {
position: absolute;
padding: 20px;
text-align: center;
box-sizing: border-box;
top: 100%;
height: calc(100% - 100px);
transition: 0.5s;
}
.container .box:hover .content {
top: 100px;
opacity: 1;
}
.container .box .content h3 {
margin: 0 0 10px;
padding: 0;
color: #fff;
font-size: 24px;
}
.container .box .content p {
margin: 0;
padding: 0;
color: #fff;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<div class="container">
<div class="box">
<div class="icon"><i class="fas fa-search"></i></div>
<div class="content">
<h3>Search</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.</p>
</div>
</div>
<div class="box">
<div class="icon"></div>
</div>
<div class="box">
<div class="icon"></div>
</div>
</div>
Developer tools are your friend. Inspect the element and you will see that your <div class="content"> div is still visible on the page even when you don't hover. Changing the <p> color to black will reveal this.
Solution: Add overflow: hidden to your .box class so the .content div will remain hidden unless you hover the .box div
.container .box {
position: relative;
width: calc(400px - 30px);
height: calc(300px - 30px);
background-color: #000;
float: left;
margin: 15px;
box-sizing: border-box;
border-radius: 10px;
overflow: hidden; /* ADD THIS */
}

How to make overlay when image hover

So, I have gallery that contains some photos. I want to make when the image hovered then some information of the person is shows up, the name of person and the their role.
.gallery {
position: relative;
padding: 6px 6px;
float: left;
width: 24.99999%;
}
.flag {
border: 1px solid #ccc;
padding: 5px;
}
.flag img {
display: block;
width: 100%;
height: auto;
}
.biodata {
position: absolute;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
color: white;
width: 100%;
height: 0;
transition: .5s ease;
}
<div class="gallery">
<div class="flag">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
<div class="biodata"> HIS NAME<br/> HIS JOB </div>
</div>
</div>
I used overlay to make the info shows up, but why the text is not in order and its not on the photo? I want its in the middle bottom on the photo. any suggestion? thanks before.
below is updated snippet
.gallery {
position: relative;
padding: 6px 6px;
float: left;
width: 24.99999%;
}
.flag {
border: 1px solid #ccc;
padding: 5px;
position:relative;
}
.flag img {
display: block;
width: 100%;
height: auto;
}
.biodata {
position: absolute;
bottom: 5px;
left: 5px;
right: 0;
overflow: hidden;
color: white;
width: calc(100% - 10px) ;
height: 0;
transition: .5s ease;
display:block;
background:rgba(0,0,0,0.5);
}
.flag:hover .biodata{
height:calc(100% - 10px);
}
<div class="gallery">
<div class="flag">
<img src="https://placeholdit.imgix.net/~text?txtsize=28&txt=300%C3%97300&w=300&h=300">
<div class="biodata"> HIS NAME<br/> President of INASGOC </div>
</div>
</div>
See this fiddle
CSS
.biodata {
z-index:100;
}
.flag:hover .biodata {
height:100%
}
Use this Code:
<!DOCTYPE html>
<html>
<head>
<style>
.container {
position: relative;
width: 50%;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: #008CBA;
overflow: hidden;
width: 100%;
height:0;
transition: .5s ease;
}
.container:hover .overlay {
bottom: 0;
height: 100%;
}
.text {
white-space: nowrap;
color: white;
font-size: 20px;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="container">
<img src="https://upload.wikimedia.org/wikipedia/commons/8/83/Shaki_Waterfall2.jpg" alt="Avatar" class="image">
<div class="overlay">
<div class="text">
<p style="padding:20px;">I am Mr. Alven</p>
</div>
</div>
</div>
</body>
</html>
​

Need help creating slated or angled divs CSS/HTML

I need help creating responsive divs with background images that have a slant or angle in them with no border to achvive a look like this:
http://jsfiddle.net/b4zjs60k/
<div class="rr-left">
</div>
<div class="rr-right">
</div>
I have tried using background images with this solution, the only problem is the angled borders are color and if I add a background image to that it looks all messed up.
I've seen this one: http://codepen.io/jefflupinski/pen/azvsA but the only problem with the skew is that I need to have the left and right sides to be straight
So i was wondering if anyone has found a solution to make both divs touch and have responsive backgrounds or combine both in a way to incorporate images
thanks hopefully this makes sense
Try the method below and adjust as needed.
#holder {
height: auto;
width: auto;
float: left;
overflow: hidden;
font-family: calibri;
background-color: white;
position: relative;
}
#holder .content {
display: inline-block;
width: 45%;
text-align: center;
position: relative;
color: white;
cursor: pointer;
background: #2c3e50;
margin-left: 0;
z-index: 2;
}
#holder .content:hover {
background-color: #425160;
}
.content:hover .line {
background: #425160!important;
}
#holder .line {
-ms-transform: rotate(10deg);
/* IE 9 */
-webkit-transform: rotate(10deg);
/* Chrome, Safari, Opera */
transform: rotate(10deg);
border-left: solid 1px white;
position: absolute;
right: 89%;
display: block;
width: 40px;
background: inherit;
height: 250px;
bottom: -10px;
z-index: -1;
}
p,
h3 {
padding: 0 30px 0 30px;
text-align: left;
width: 70%;
}
h3 {
font-size: 24px;
line-height: 24px;
margin-bottom: 0;
}
<div id="holder">
<div class="content">
<h3>This is a header</h3>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p>
</div>
<div class="content">
<div class="line"></div>
<h3>This is a header</h3>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p>
</div>
</div>
<!-- End Holder -->
Here is my answer, using skew, but in a container that has overflow hidden
.header {
width: 100%;
height: 0%;
padding-bottom: 25%;
position: relative;
overflow: hidden;
}
.left {
width: 60%;
height: 100%;
position: absolute;
right: 50%;
top: 0px;
transform: skew(-20deg);
overflow: hidden;}
.right {
width: 60%;
height: 100%;
position: absolute;
left: 50%;
top: 0px;
transform: skew(-20deg);
overflow: hidden;
}
.innerleft {
content: "";
position: absolute;
width: 100%;
height: 100%;
background-image: url(http://placekitten.com/800/400);
transform: skew(20deg);
left: 10%;
background-size: cover;
}
.leftcontent {
position: absolute;
left: 100px;
top: 60px;
color: white;
font-size: 40px;
}
.right:after {
content: "";
position: absolute;
width: 100%;
height: 100%;
background-image: url(http://placekitten.com/600/500);
transform: skew(20deg);
right: 10%;
background-size: cover;
}
<div class="header">
<div class="left">
<div class="innerleft">
<div class="leftcontent">LEFT</div>
</div>
</div>
<div class="right"></div>
</div>