简体   繁体   中英

Present am getting content on same div on hover, i want content should show on next div on hover the first div

Present am getting content on same div on hover, I want content should show on next div on hover the first div. required output image ,please help on this issue. In this output we have four boxes, 2X2 boxes, I want content should show on next box on hover In this code, I just used HTML and CSS so I want small change in this , just show the content on next div on hover

 .four-divs { width: 322px; height: 151px; background-color: #000000; margin-left: 3px; margin-bottom: 6px; } .four-divs img { width: 25%; margin-left: auto; margin-right: auto; display: block; padding: 8px 0px; margin-bottom: 10px; } .global-mobility-strategy { float: left; } .assignment-policy-reference { float: right; } .client-projrct-tools { float: left; } .additional-assignment-references { float: right; } .mobility-opportunities { width: 100%; height: 151px; background-color: #000000; } .four-divs .inner-div-content { align-content: center; } .inner-div-content h3 { color: #FFFFFF; display: block; margin: 0 auto; padding: 0; font-size: 16px; /* font-family: open sand; */ text-align: center; margin-top: -10px; } .mobility-opportunities img { width: 13%; margin-left: auto; margin-right: auto; display: block; padding: 10px 0px; margin-bottom: 20px; } .image-container { float: left; overflow: hidden; position: relative; } .image-container .mask, .image-container .content { width: 322px; height: 151px; position: absolute; overflow: hidden; top: 0; left: 0; } .image-container img { display: block; position: relative; } .image-container a.info { text-decoration: none; padding: 0; text-indent: -9999px; width: 20px; height: 20px; background-color: black !important; color: white !important; padding: 6px 13px; text-align: center !important; } .effect .mask { opacity: 0; overflow: visible; box-sizing: border-box; // transition: all 0.4s ease-in-out; } .effect a.info { position: relative; top: 0px; /* Center the link */ opacity: 0; // transition: opacity 0.5s 0s ease-in-out; } .effect:hover .mask { opacity: 1; font-size: 13px; text-align: center; padding: 7px; background-color: #86BC25; } .effect:hover .mask h3 { font-weight: bold; font-size: 14px; margin: 0px; text-align: center; //padding: 6px; background-color: #86BC25; height: 30px; } .effect:hover a.info { opacity: 1; background-color: red; color: black; //transition-delay: 0.3s; }
 <div class="main-four-divs"> <div class="hover-div" style="width: 650px; height: 315px; background-color: #FFFFFF; "> <div class="global-mobility-strategy image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Global Mobility Strategy" /> <h3 style="line-height: 23px; font-weight: bold;"> Communications </h3> <img src="arrow-new.jpg" alt="arrow" style=" width: 5%; margin: -23px 0px -2px 296px; "> </div> <div class="mask"> <h3>Communications Toolkit</h3> <p style="height: 62px;margin: 10px 0px;color:#FFFFFF;font-size:14px;margin-top: 13px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <a href="#" class="info">Read more</a> </div> </div> <div class="assignment-policy-reference image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Assignment Policy References" /> <h3 style="line-height: 35px;font-weight: bold;">Assignment </h3> <img src="arrow-new.jpg" alt="arrow" style=" width: 5%; margin: -10px 0px -2px 296px; "> </div> <div class="mask"> <h3>Assignment</h3> <p style="height: 62px;margin: 28px 0px;color:#FFFFFF;font-size:14px;margin-top: -4px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <a href="#" class="info">Read more</a> </div> </div> <div class="client-projrct-tools image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Client Project Tools" /> <h3 style="line-height: 35px;font-weight: bold;">Client Project</h3> <img src="arrow-new.jpg" alt="arrow" style=" width: 5%; margin: -10px 0px -2px 296px; "> </div> <div class="mask"> <h3 style="line-height: 35px;">Client Project </h3> <p style="height: 62px;margin: 10px 0px;color:#FFFFFF;font-size:14px;margin-top: 13px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <a href="#" class="info">Read more</a> </div> </div> <div class="additional-assignment-references image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Additional Assignment References" /> <h3 style="line-height: 35px;font-weight: bold;">Additional Assignment References</h3> <img src="arrow-new.jpg" alt="arrow" style=" width: 5%; margin: -10px 0px -2px 296px; "> </div> <div class="mask"> <h3 style="line-height: 35px;">Additional</h3> <p style="height: 62px;margin: 10px 0px;color:#FFFFFF;font-size:14px;margin-top: 13px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s .</p> <a href="#" class="info">Read more</a> </div> </div> </div> </div>

You can achieve this effect by simply modify and add some CSS . You can change overlay box position using transform: translateX(); CSS when you hover the parent. And set negative position of overlay using nth-child(even) CSS

Here is Demo

 .four-divs { width: 322px; height: 151px; background-color: #000000; margin-left: 3px; margin-bottom: 6px; } .four-divs img { width: 25%; margin-left: auto; margin-right: auto; display: block; padding: 8px 0px; margin-bottom: 10px; } .global-mobility-strategy { float: left; } .assignment-policy-reference { float: right; } .client-projrct-tools { float: left; } .additional-assignment-references { float: right; } .mobility-opportunities { width: 100%; height: 151px; background-color: #000000; } .four-divs .inner-div-content { align-content: center; } .inner-div-content h3 { color: #FFFFFF; display: block; margin: 0 auto; padding: 0; font-size: 16px; /* font-family: open sand; */ text-align: center; margin-top: -10px; } .mobility-opportunities img { width: 13%; margin-left: auto; margin-right: auto; display: block; padding: 10px 0px; margin-bottom: 20px; } .image-container { float: left; /* overflow: hidden; */ position: relative; } .image-container .mask, .image-container .content { width: 322px; height: 151px; position: absolute; overflow: hidden; top: 0; left: 0; } .image-container img { display: block; position: relative; } .image-container a.info { text-decoration: none; padding: 0; text-indent: -9999px; width: 20px; height: 20px; background-color: black !important; color: white !important; padding: 6px 13px; text-align: center !important; } .effect .mask { opacity: 0; overflow: visible; box-sizing: border-box; // transition: all 0.4s ease-in-out; } .effect a.info { position: relative; top: 0px; /* Center the link */ opacity: 0; // transition: opacity 0.5s 0s ease-in-out; } .effect:hover .mask { opacity: 1; font-size: 13px; text-align: center; padding: 7px; background-color: #86BC25; transform: translateX(100%); z-index: 1; margin-left: 3px; } .effect:nth-child(even):hover .mask { transform: translateX(-100%); margin-left: -3px; margin-right: 0px; } .effect:hover .mask h3 { font-weight: bold; font-size: 14px; margin: 0px; text-align: center; //padding: 6px; background-color: #86BC25; height: 30px; } .effect:hover a.info { opacity: 1; background-color: red; color: black; //transition-delay: 0.3s; }
 <div class="main-four-divs"> <div class="hover-div" style="width: 650px; height: 315px; background-color: #FFFFFF;"> <div class="global-mobility-strategy image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Global Mobility Strategy" /> <h3 style="line-height: 23px; font-weight: bold;"> Communications </h3> <img src="arrow-new.jpg" alt="arrow" style="width: 5%; margin: -23px 0px -2px 296px;"> </div> <div class="mask"> <h3>Communications Toolkit</h3> <p style="height: 62px;margin: 10px 0px;color:#FFFFFF;font-size:14px;margin-top: 13px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <a href="#" class="info">Read more</a> </div> </div> <div class="assignment-policy-reference image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Assignment Policy References" /> <h3 style="line-height: 35px;font-weight: bold;">Assignment </h3> <img src="arrow-new.jpg" alt="arrow" style="width: 5%; margin: -10px 0px -2px 296px;"> </div> <div class="mask"> <h3>Assignment</h3> <p style="height: 62px;margin: 28px 0px;color:#FFFFFF;font-size:14px;margin-top: -4px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <a href="#" class="info">Read more</a> </div> </div> <div class="client-projrct-tools image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Client Project Tools" /> <h3 style="line-height: 35px;font-weight: bold;">Client Project</h3> <img src="arrow-new.jpg" alt="arrow" style="width: 5%; margin: -10px 0px -2px 296px;"> </div> <div class="mask"> <h3 style="line-height: 35px;">Client Project </h3> <p style="height: 62px;margin: 10px 0px;color:#FFFFFF;font-size:14px;margin-top: 13px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <a href="#" class="info">Read more</a> </div> </div> <div class="additional-assignment-references image-container four-divs effect"> <div class="inner-div-content"> <img src="icon-22.jpg" alt="Additional Assignment References" /> <h3 style="line-height: 35px;font-weight: bold;">Additional Assignment References</h3> <img src="arrow-new.jpg" alt="arrow" style="width: 5%; margin: -10px 0px -2px 296px;"> </div> <div class="mask"> <h3 style="line-height: 35px;">Additional</h3> <p style="height: 62px;margin: 10px 0px;color:#FFFFFF;font-size:14px;margin-top: 13px;">is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s .</p> <a href="#" class="info">Read more</a> </div> </div> </div> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM