简体   繁体   中英

arrow hover adding a circle div behind

I have two arrow images (previous / next) with the code here like this:

.fp-controlArrow {
    position: absolute;
    width: 32px; /* This can be added here so you don't have to set a width and height 2 times for each arrow, this will create one width for both arrows */
    height: 32px; /* This does the same as above */
    margin-top:-15px; /* This value must always be half of the height - This does the same as above */
    z-index: 30;
    top: 50%;
    cursor: pointer;
}

.fp-controlArrow.fp-prev {
    left:0;
    background: url(https://uploads-ssl.webflow.com/602dbecd2160ce28b5bc428b/602e923133f8dc0bf994fc49_left-arrow.svg) no-repeat;
}
.fp-controlArrow.fp-next {
    right:0;
    background: url(https://uploads-ssl.webflow.com/602dbecd2160ce28b5bc428b/602e9231ec03b6c9682b540c_right-arrow.svg) no-repeat;

I would like when I hover over an arrow it a round transparent circle appeared behind the arrow like on this example:

enter image description here

how can I achieve this?

thank you!

padding: 1em;
border-radius: 50%;
background-color: rgba(200,200,200,0.5)

Add those lines to the .fp-controlArrow class That should do it.

Edit

Sorry, I didn't realize it was svg. You will have to inline the svg.

<div class="fp-controlArrow fp-prev">

  <svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-reactroot="">
    <path stroke-linejoin="round" stroke-linecap="round" stroke-width="1" stroke="#221b38" d="M16 20L8 12L16 4"></path>
  </svg>

</div>
<div class="fp-controlArrow fp-next">

  <svg width="32" height="32" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-reactroot="">
    <path stroke-linejoin="round" stroke-linecap="round" stroke-width="1" stroke="#221b38" d="M8 20L16 12L8 4"></path>
  </svg>

</div>
.fp-controlArrow {
    position: absolute;
    width: 32px; /* This can be added here so you don't have to set a width and height 2 times for each arrow, this will create one width for both arrows */
    height: 32px; /* This does the same as above */
    margin-top:-15px; /* This value must always be half of the height - This does the same as above */
    z-index: 30;
    top: 50%;
    cursor: pointer;
    padding: 1em;
    border-radius: 50%;

}

.fp-controlArrow:hover {
  background: green;
  background-color: rgba(200,200,200,0.5);
} 

.fp-controlArrow.fp-prev {
    left:0;
}
.fp-controlArrow.fp-next {
    right:0;
  

Here is a codepen that demonstrates it.

Sorry, I didn't saw the space between: and hover.

.fp-controlArrow.fp-prev {
left:0;
background: url(https://uploads-ssl.webflow.com/602dbecd2160ce28b5bc428b/602e923133f8dc0bf994fc49_left-arrow.svg) no-repeat;
border-radius: 50px;
}
.fp-controlArrow.fp-prev:hover{
background-color: #999999;
}

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