I have this code:
.container {
margin-right: auto;
margin-left: auto;
max-width: 1400px;
padding-left: 1rem;
padding-right: 1rem;
}
.grid { display: grid }
.vh-100 { min-height: 100vh;}
.grid-gap { grid-gap: 0.7rem; }
.flex { display: flex; -webkit-display: flex; -moz-display: flex; -ms-display: flex; -o-display: flex; }
.text-center { text-align: center; }
.flex-dir-col { flex-direction: column; }
.relative { position: relative; }
.absolute { position: absolute; }
.img-fluid { max-width: 100%; height: auto; }
.content-wrapper .container {
grid-auto-flow: row dense;
-ms-grid-columns: 3fr 1fr;
grid-template-columns: 3fr 1fr;
-ms-grid-rows: 1fr;
grid-template-rows: 1fr;
gap: 0px 35px;
}
.content-wrapper .container .main-content {
-ms-grid-row: 1;
-ms-grid-row-span: 1;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
grid-area: 1 / 1 / 2 / 3;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-sharing .icon {
width: 50px;
height: 50px;
background-color: #f1f1f1;
margin-bottom: 20px;
border-radius: 30%;
-webkit-border-radius: 30%;
-moz-border-radius: 30%;
-ms-border-radius: 30%;
-o-border-radius: 30%;
color: #3ab77d;
-webkit-box-shadow: 0px 5px 15px -5px #00000070;
box-shadow: 0px 5px 15px -5px #00000070;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-sharing .icon i {
line-height: 50px;
font-size: 20px;
transition: all .4s;
-webkit-transition: all .4s;
-moz-transition: all .4s;
-ms-transition: all .4s;
-o-transition: all .4s;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-sharing .icon:hover {
background-color: #3ab77d;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-sharing .icon:hover i {
color: #f1f1f1;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-featured-image {
overflow: hidden;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-featured-image .post-date {
top: 1rem;
left: 1rem;
background-color: #fff;
width: 50px;
height: 50px;
line-height: 1.5;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-featured-image .post-date .day {
font-size: 1rem;
padding-top: .2rem;
}
.content-wrapper .container .main-content .post-content .post-content-top .post-featured-image .post-date .month {
font-size: 0.75rem;
}
.content-wrapper .container .sidebar {
-ms-grid-row: 1;
-ms-grid-row-span: 1;
-ms-grid-column: 2;
-ms-grid-column-span: 1;
grid-area: 1 / 2 / 2 / 3;
position: relative;
background-color: rgba(255, 0, 0, 0.468);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.8.3/font/bootstrap-icons.css" rel="stylesheet"/>
<section class="content-wrapper mt-2 mb-2">
<div class="container grid vh-100 grid-gap">
<div class="main-content">
<div class="post-content">
<div class="post-content-top flex">
<div class="post-sharing flex flex-dir-col mr-1 text-center">
<i class="bi bi-facebook"></i>
<i class="bi bi-twitter"></i>
<i class="bi bi-reddit"></i>
<i class="bi bi-whatsapp"></i>
</div>
<div class="post-featured-image relative">
<img src="https://cdn.pixabay.com/photo/2022/06/14/17/30/beach-7262493_1280.jpg" class="img-fluid">
<div class="post-date absolute flex flex-dir-col text-center">
<span class="day">23</span>
<span class="month">JUL</span>
</div>
</div>
</div>
</div>
</div>
<div class="sidebar">
This is the sidebar
</div>
</div>
</section>
So this should be a blog like layout with a main content and a sidebar on the right. My problem is that the image is overflowing its div and it flows underneath the sidebar. I added a slightly transparent background color to the sidebar so it's more visible.
I tried to add max-width: 100% and height: auto; to the image as recommended here, but it didn't work. I also tried to add overflow: hidden to the parent div of the image, but no luck. But I wouldn't want to clip the image anyway.
I don't understand because max-width: 100% and height: auto; should make the image responsive, right?
Any idea what I'm doing wrong? Thanks
There are 2 ways to achieve this:
You can cut the image which is being overflowed.
overflow-x: hidden;
You can either give detailed stylings, like this
*{
margin: 0;
padding:0;
}
img{
width: 100%;
height: 100%;
}
.image_container{
max-width: 100vw;
max-height: 100vw;
}
<div class="image_container">
<img src="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/80a9d98d-327f-4bb2-b173-4298d710e51c/derkflv-9f975f3d-791f-4e16-8d9d-fb0a9e5e0554.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzgwYTlkOThkLTMyN2YtNGJiMi1iMTczLTQyOThkNzEwZTUxY1wvZGVya2Zsdi05Zjk3NWYzZC03OTFmLTRlMTYtOGQ5ZC1mYjBhOWU1ZTA1NTQucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.eEDVAlJGBqXo6OeZEORXWk1veGSHFL-ZTUMz43Jtr3Q" alt="image">
<div>
Related
I struggle with an responsive attempt. I got two columns, where the width is based on VW. The bigger column contains am div element to close. This element should have always the same top and left margin, in relatives to the parent column. No matter if I resize the window.
Currently if I resize the distance between changes, either increase or shrinks to a point, where my close div get out of position c
body {
background: grey;
overflow: hidden;
}
.container-fluid {
width: 100%;
margin: auto;
display: flex;
flex-wrap: inherit;
align-items: center;
justify-content: space-between;
}
.col-lg-8 {
flex: 0 0 auto;
width: 66.666667%;
}
.col-lg-4 {
flex: 0 0 auto;
width: 33.333333%;
}
.card {
position: relative;
display: flex;
flex-direction: column;
height: 50vh;
background-color: #fff;
background-clip: border-box;
border: 0 solid rgba(0, 0, 0, 0.125);
border-radius: 1rem;
margin: 0.5em;
padding: 0.5em;
}
.title {
margin: 0.5em;
font-size: 3em;
float: left;
}
.close-btn {
position: absolute;
float: left;
cursor: pointer;
font-size: 2em;
left: 57vw;
top: 2vh;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Fixed Close Position</title>
<!-- fontawesome stylesheet https://fontawesome.com/ -->
<script src="https://kit.fontawesome.com/98a5e27706.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
<div class="col-lg-8">
<div class="card">
<div class="title">Headline</div>
<div class="close-btn"><i class="fa-solid fa-circle-xmark"></i></div>
</div>
</div>
<div class="col-lg-4">
<div class="card">
<div class="title">News</div>
</div>
</div>
</div>
</body>
</html>
ompletely. I am stuck.
Try this,
body {
background: grey;
overflow: hidden;
}
.container-fluid {
width: 100%;
margin: auto;
display: flex;
flex-wrap: inherit;
align-items: center;
justify-content: space-between;
}
.col-lg-8 {
flex: 0 0 auto;
width: 66.666667%;
}
.col-lg-4 {
flex: 0 0 auto;
width: 33.333333%;
}
.card {
position: relative;
display: flex;
flex-direction: column;
height: 50vh;
background-color: #fff;
background-clip: border-box;
border: 0 solid rgba(0, 0, 0, 0.125);
border-radius: 1rem;
margin: 0.5em;
padding: 0.5em;
}
.title {
margin: 0.5em;
font-size: 3em;
float: left;
}
.close-btn {
position: absolute;
cursor: pointer;
font-size: 2em;
left: auto;
top: 2vh;
right: 2vh;
}
Goal:
Mouse hovering over the picture and its area, the title and content will raise up.
The contents background and height should go to the bottom of the area.
Problem:
The title and contents background don't go all the way down to the button.
I don't know how to do.
Please take a look at the picture for visual communication.
JSBin:
https://jsbin.com/xenavotemu/edit?html,output
Thank you!
.cards {
margin: 0 auto;
display: grid;
grid-gap: 5px;
}
.card {
width: 100%;
min-height: 100px;
background-color: #e6e6e6;
text-align: center;
border: 1px solid white;
transition: border 1s;
position: relative;
}
.card:hover {
border: 1px solid black;
}
.card .wrapper {
bottom: 0;
position: absolute;
transition: all .3s ease;
width: 100%;
}
.card:hover .wrapper {
bottom: 30px;
transform: translateY(-50%)
}
.cardTitle {
width: 100%;
margin-top: -4px;
color: white;
background-color: grey;
font-size: xx-large;
}
.cardText {
background-color: #fff;
height: 0;
opacity: 0;
visibility: hidden;
}
.card:hover .cardText {
height: 100%;
;
opacity: 1;
visibility: visible;
}
.responsive {
width: 300px;
}
/* 2 column */
#media (min-width: 700px) and (max-width: 899px) {
div.cards {
grid-template-columns: repeat(2, 1fr);
}
}
/* 3 columns */
#media (min-width: 900px) {
div.cards {
grid-template-columns: repeat(3, 1fr);
}
}
<div class="cards">
<div class="card">
<img src="https://dogtowndogtraining.com/wp-content/uploads/2012/06/300x300-061-e1340955308953.jpg" class="responsive" alt="" />
<div class="wrapper">
<div class="cardTitle">ONE</div>
<div class="cardText">aaa<br /> aaaa</div>
</div>
</div>
<div class="card">
<img src="https://dogtowndogtraining.com/wp-content/uploads/2012/06/300x300-061-e1340955308953.jpg" class="responsive" alt="" />
<div class="wrapper">
<div class="cardTitle">ONE</div>
<div class="cardText">aaa<br /> aaa<br /> aaa</div>
</div>
</div>
<div class="card">
<img src="https://dogtowndogtraining.com/wp-content/uploads/2012/06/300x300-061-e1340955308953.jpg" class="responsive" alt="" />
<div class="wrapper">
<div class="cardTitle">ONE</div>
<div class="cardText">aaa<br /> aaa<br /> aaa<br /> aaa</div>
</div>
</div>
</div>
Using the technic from this answer:
https://stackoverflow.com/a/8331169/10839134
Removed following style because it's causing the height problem.
.card:hover .wrapper {
bottom: 30px;
transform: translateY(-50%);
}
Instead of changing the visibility on .cardText I change the max-height:
.cardText {
background-color: #fff;
height: 0;
opacity: 0;
max-height: 0;
}
.card:hover .cardText {
height: 100%;
opacity: 1;
max-height: 500px;
transition: max-height 0.25s ease-in;
}
https://jsbin.com/xowematuki/1/edit?html,css,js,output
The idea is to put the image inside it's own wrapper that will shrink from the bottom up (from 100% to 70% in this example). Of course, all overflow hidden.
.cards {
margin: 0 auto;
display: grid;
grid-gap: 5px;
}
.card {
width: 100%;
min-height: 100px;
background-color: #e6e6e6;
text-align: center;
border: 1px solid white;
transition: border 1s;
position: relative;
}
.card:hover {
border: 1px solid black;
}
.card .wrapper {
bottom: 0;
position: absolute;
transition: all .3s ease;
width: 100%;
}
.card:hover .wrapper {
bottom: 30px;
transform: translateY(-50%)
}
.cardTitle {
width: 100%;
margin-top: -4px;
color: white;
background-color: grey;
font-size: xx-large;
}
.cardText {
background-color: #fff;
height: 0;
opacity: 0;
visibility: hidden;
}
.card:hover .cardText {
height: 100%;
opacity: 1;
visibility: visible;
}
.responsive {
width: 300px;
}
.img-wrapper {
height: 100%;
position: relative;
overflow: hidden;
transition: all .3s ease;
}
.card:hover .img-wrapper {
height: 70%;
}
.card {
overflow: hidden;
}
<div class="cards">
<div class="card">
<div class="img-wrapper">
<img src="https://dogtowndogtraining.com/wp-content/uploads/2012/06/300x300-061-e1340955308953.jpg" class="responsive" alt="" />
</div>
<div class="wrapper">
<div class="cardTitle">ONE</div>
<div class="cardText">aaa<br /> aaaa</div>
</div>
</div>
</div>
[https://codepen.io/TA0011/pen/VwXKKgG]
When viewed in mobile version, the width of the card exceeds the Content hr (horizontal line). What can be done so that it does not exceed the horizontal line? Do not go with the 5 fr or 1fr unit. I can manage the 1 fr or 5fr scene. But only problem is with the card that exceeds the hr line which is blue in color.
.container-a {
margin-top: 10px;
width: calc(100% - 100px);
margin: 10px auto;
position: relative;
}
.container-a span {
background-color: #007bff;
padding: 5px 10px;
position: relative;
color: #fff;
z-index: -1;
background-blend-mode: multiply;
}
.container-a hr {
width: 100%;
color: #007bff;
margin-top: 4px;
height: 1px;
position: relative;
z-index: -2;
}
.container-a .wrapper {
display: grid;
height: 100%;
grid-template-columns: repeat(5, 1fr);
grid-template-areas: "blog-container blog-container blog-container blog-container blog-sidebar";
grid-gap: 10px;
}
.container-a .blog-container {
grid-area: blog-container;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
grid-gap: 10px;
}
.card {
min-width: 280px;
flex: 1;
-webkit-box-flex: 1;
-ms-flex: 1;
height: 180px;
width: 100%;
border: 1px solid #ccc;
background: #FF7F50;
font-weight: 500 !important;
position: relative;
color: #fff;
}
.container-a .blog-sidebar {
grid-area: blog-sidebar;
}
.blog-sidebar .widgets {
background: #fff;
border: 1px solid #ccc;
margin-bottom: 10px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
grid-gap: 10px;
padding: 5px;
}
.widgets img {
width: 100%;
float: none;
display: block;
object-fit: fill;
}
.blog-sidebar h3 {
color: #007bff;
text-align: center;
margin-top: 2px 0 2px 0;
margin: -1px 0 -1px 0;
}
#media(max-width: 768px) {
.container-a {
width: calc(100% - 60px);
}
.container-a span {
font-size: 12px;
}
.container-a hr {
margin-top: 3px;
}
.container-a {
width: calc(100% - 60px);
margin-bottom: 100px;
}
.container-a .wrapper {
grid-template-rows: auto;
grid-template-columns: 1fr;
grid-template-areas: "blog-container" "blog-sidebar";
}
.card {
min-width: 244px;
}
}
<section class="container-a" aria-label="blog-content">
<span>Content</span>
<hr>
<div class="wrapper">
<div class="blog-container">
<div class="card">Card 1</div>
<div class="card">Card 2</div>
<div class="card">Card 3</div>
<div class="card">Card 4</div>
<div class="card">Card 5</div>
</div>
<div class="blog-sidebar">
<h3>Sidebar</h3>
<div class="widgets">
<div class="card">Card 1</div>
<div class="card">Card 2</div>
</div>
</div>
</div>
</section>
[I have done it , you can view it][1]
[1]: https://codepen.io/TA0011/pen/ZExJgmr
I have searched all over stack overflow but I am unable to find any clue and I am struck here. I used flex container and child items in my code to some extent but I couldn't move beyond that. Thing is when we hover a child item, a new child item need to be created as shown in the expected result. Should we need to use pseudo element or any other flex properties to achieve this. Thanks much in advance.
My code:
https://jsfiddle.net/k2qr398u/1/
My result
https://imgur.com/kRHNHuu
Expected result:
https://imgur.com/2B6CkYF
/**CSS**/
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
background-color: #400017;
}
.img-css {
width: 50px;
height: 50px;
}
.main-heading {
display: block;
text-align: center;
color: #fc065d;
margin-bottom: 70px;
}
.img-js {
width: 50px;
height: 50px;
}
.container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
border: 3px solid #360310;
max-width: 610px;
height: 310px;
text-align: center;
margin: 0 auto;
flex-direction: row;
/* transform: translate(-50%,-50%); */
}
.col {
width: 130px;
height: 100px;
margin: 0 auto;
border: 3px solid #5e0a1f;
padding-top: 44px;
padding-left: 26px;
padding-right: 26px;
color: #fff;
background-color: #010001;
border-radius: 30px;
z-index: 20;
/* position: relative; */
}
.col p {
font-size: 16px;
font-weight: bold;
}
.col-2 p {
position: relative;
top: 55px;
text-align: center;
font-weight: bold;
}
<!--**HTML**-->
<body>
<div class="container">
<div class="col col-1">
<img src="images/css.svg" alt="CSS logo" class="img-css">
<br>
<p>I am</p>
</div>
<div class="col col-2">
<p class="my-name">Sri</p>
</div>
<div class="col col-3">
<img src="images/javascript.svg" alt="JS logo" class="img-js">
<p>Developer
</p>
</div>
</div>
</body>
P.S: Sorry if this question sounds very silly or dumb, I am a beginner trying to learn web dev skillsets.
I have created something similar to your expected result. Please run the code snippet for the result.
UPDATE: To include the hover off transition.
/**CSS**/
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
background-color: #400017;
}
.img-css {
width: 50px;
height: 50px;
}
.main-heading {
display: block;
text-align: center;
color: #fc065d;
margin-bottom: 70px;
}
.img-js {
width: 50px;
height: 50px;
}
.container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
border: 3px solid #360310;
max-width: 610px;
height: 310px;
text-align: center;
margin: 0 auto;
flex-direction: row;
/* transform: translate(-50%,-50%); */
}
.col {
width: 130px;
height: 100px;
margin: 0 auto;
border: 3px solid #5e0a1f;
padding-top: 44px;
padding-left: 26px;
padding-right: 26px;
color: #fff;
background-color: #010001;
border-radius: 30px;
z-index: 20;
position: relative;
}
.col p {
font-size: 16px;
font-weight: bold;
}
/*
.col-2 p {
position: relative;
top: 55px;
text-align: center;
font-weight: bold;
}
*/
.col-1,
.col-2-1,
.col-2-2,
.col-3 {
position: absolute;
left: 0;
top: 0;
transition: 1s;
}
.wrapper {
position: relative;
}
.wrapper:hover .col-1 {
transition: 1s;
left: -200px;
}
.wrapper:hover .col-2-1 {
transition: 1s;
top: -170px;
}
.wrapper:hover .col-2-2 {
transition: 1s;
top: 170px;
}
.wrapper:hover .col-3 {
transition: 1s;
left: 200px;
}
<!--**HTML**-->
<body>
<div class="container">
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-1">
<img src="images/css.svg" alt="CSS logo" class="img-css">
<br>
<p>I am</p>
</div>
</div>
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-2-1">
<p class="my-name">Sri</p>
</div>
<div class="col col-2-2">
<p class="my-name">Pratham</p>
</div>
</div>
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-3">
<img src="images/javascript.svg" alt="JS logo" class="img-js">
<p>Developer
</p>
</div>
</div>
</div>
</body>
The idea is:
Overlay some content over main content.
On hover reveal it :)
.card {
width: 150px;
height: 80px;
border: 1px solid #999;
background: #ccc;
border-radius: 8px;
position: relative;
margin: 20% auto;
}
.card:hover > .o-top {
top: -80px;
background: #f00;
}
.card:hover > .o-bottom {
bottom: -80px;
}
.o-top {
top: 0;
transition: top 1.5s, background 2s;
}
.o-bottom {
bottom: 0;
transition: bottom 1.5s, background 2s;
}
.card-overlay {
position: absolute;
height: 100%;
width: 100%;
background: #333;
pointer-events: none;
color: #fff;
}
<div class="card">
<div class="card-overlay o-top">TOP OVERLAY</div>
<div class="card-overlay o-bottom">BOTTOM OVERLAY</div>
<H3>INTERNAL CONTENT</H3>
</div>
I have two side by side divs. The right div is set to expand on hover and display a message. I have set the z-index on the expanding div to be z-index: 1 and the left div and all its children to be z-index: 0, however the expanding div will only expand as far as the text in the div beside it.
I have read multiple questions here about z-index and flex items but can't work out what I am doing wrong. I have added a higher z-index to my first flex-item as described here Z-index doesn't work with flex elements? but that has not fixed it.
.container {
display: flex;
background-color: lightgray;
height: 48px;
width: 139px;
border-radius: 4px;
}
.container .inner {
height: 48px;
}
.container .inner > div {
display: flex;
z-index: 0;
}
.container .inner.left {
display: flex;
flex-direction: column;
flex: 1 0 auto;
padding-left: 10px;
justify-content: center;
}
.container .inner.right {
display: flex;
flex: 0 1 8px;
background-color: red;
border-radius: 0 4px 4px 0;
overflow: hidden;
transition: 0.3s;
cursor: pointer;
z-index: 1;
}
.container .inner.right .info-msg {
display: none;
transition: 0.3s;
}
.container .inner.right:hover {
flex: 0 1 150px;
}
.container .inner.right:hover .info-msg {
display: flex;
}
<div class="container">
<div class="inner left">
<div class="time">9:00am - 5:00pm</div>
<div class="name">Worker</div>
</div>
<div class="inner right">
<div class="info-msg">Message</div>
</div>
</div>
Z-Index is not the issue here. You can set the position to absolute so the right div goes over the left on hover.
This code works:
.container {
height: 48px;
width: 139px;
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
background-color: lightgray;
border-radius: 4px;
}
.inner {
padding-left: 10px;
}
.right {
height: 48px;
width: 8px;
position: absolute;
right: 0px;
display: flex;
align-items: center;
background-color: red;
border-radius: 0 4px 4px 0;
transition: 0.7s;
cursor: pointer;
}
.right:hover {
width: 129px;
border-radius: 4px;
}
.info-msg {
overflow: hidden;
}
This is not a z-index issue. It is a width issue. When the element expands the other element still occupies part of the width and therefore the expanding element stops.
You can add flex-shrink: 1 to the left element for the effect to take place. Also, you can set different position. Or you can use transform: translateX(-100%).
.container {
display: flex;
background-color: lightgray;
height: 48px;
width: 139px;
border-radius: 4px;
}
.container .inner {
height: 48px;
}
.container .inner>div {
display: flex;
z-index: 0;
}
.container .inner.left {
display: flex;
flex-direction: column;
flex: 1 0 auto;
padding-left: 10px;
justify-content: center;
/* Add flex shrink */
flex-shrink: 1;
}
.container .inner.right {
display: flex;
flex: 0 1 8px;
background-color: red;
border-radius: 0 4px 4px 0;
overflow: hidden;
transition: 0.3s;
cursor: pointer;
z-index: 1;
}
.container .inner.right .info-msg {
display: none;
transition: 0.3s;
}
.container .inner.right:hover {
flex: 0 1 150px;
}
.container .inner.right:hover .info-msg {
display: flex;
}
<div class="container">
<div class="inner left">
<div class="time">9:00am - 5:00pm</div>
<div class="name">Worker</div>
</div>
<div class="inner right">
<div class="info-msg">Message</div>
</div>
</div>
As mentioned in the comments above, you can make inner right div position: absolute with parent div position relative.
Check the snippet:
.container {
display: flex;
background-color: lightgray;
height: 48px;
width: 139px;
border-radius: 4px;
position: relative;
}
.container .inner {
height: 48px;
}
.container .inner > div {
display: flex;
z-index: 0;
}
.container .inner.left {
display: flex;
flex-direction: column;
flex: 1 0 auto;
padding-left: 10px;
justify-content: center;
}
.container .inner.right {
display: flex;
background-color: red;
border-radius: 0 4px 4px 0;
overflow: hidden;
transition: 0.3s;
cursor: pointer;
z-index: 1;
position: absolute;
right: 0;
top: 0;
bottom: 0;
left: calc(100% - 8px);
width: 8px;
padding: 5px;
box-sizing: border-box;
}
.container .inner.right .info-msg {
display: none;
transition: 0.3s;
}
.container .inner.right:hover {
left: 0;
width: 100%;
border-radius: 4px;
}
.container .inner.right:hover .info-msg {
display: flex;
}
<div class="container">
<div class="inner left">
<div class="time">9:00am - 5:00pm</div>
<div class="name">Worker</div>
</div>
<div class="inner right">
<div class="info-msg">Message</div>
</div>
</div>