html - className:hover #myID {style} -


im trying have description text on mye card(box) move 10px when hover on over pictures. reason city name text , button follows it.

no hover in card (img) here hover (img)

as u can see on second img. button jumps too.

html code card text , city name , button

    <div class="cards_container">     <div class="card" id="card_oslo">       <p class="cardcityinfo">         oslo er et kult sted <br> hvor det er mange <br>         turister året rundt. <br> så dra og besøk.       </p>       <h4 class="card_text">oslo</h4>       <a href="#"><h5 id="btn_card">se mer</h5></a>     </div> 

css code style, , how tried code :hover effect on desc. text on cards. ".card:hover .cardcityinfo" 1 i'm trying hover on text

    .cardcityinfo{       font-size: 1.1rem;       font-family: 'nunito', sans-serif;       color: #fff;       text-align: center;       z-index: 5;       margin-top: 100px;       opacity: 0;       }      .card:hover{       box-shadow: inset 0 0 0 1000px rgba(0,0,0,.7);       transition: .5s;       }      .card:hover .cardcityinfo{       opacity: 0.9 !important;       transition: .5s;       margin-top: 90px;       }      .card:hover .card_text{       color: #fff;       transition: .5s;       } 

here how card looks in css if anything...

    .card {       position:relative;       width: 315px;       height: 300px;       background-size: contain;       background-repeat: no-repeat;       background-color: #fff;       border-radius: 5px;       margin: 20px 10px;       float: left;       /*box-shadow: 0px 2px 3px #999;*/       } 

if change margin of element, change else follows in same document flow. change can use transform on element, instead of

.card:hover .cardcityinfo{   margin-top: 90px; } 

you use transform there:

.card:hover .cardcityinfo{   transform: translatey(-10px); } 

demo: https://jsfiddle.net/1jglzdn4/


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -