I am trying to achieve the following
This is my html:
btn_ol
class has <a>
and <span>
(with object svg)
<div class="btn_ol">
<a href="http://google.com/" target="_blank"></a>
<span>Google<object class=ol_svg data="../assets/images/common/icon_ol.svg" type="image/svg+xml"></object></span>
</div>
This is my css:
.btn_ol {
padding: 2.3rem 1.8rem;
border: 2px solid #0c5a9d;
cursor: pointer;
width: 604px;
display: block;
margin: 35px auto;
outline: none;
vertical-align: middle;
text-align: center;
position: relative;
overflow: hidden;
background-color: transparent;
color: #0c5a9d;
transition: background-color 300ms ease-out;
z-index: 1;
}
.btn_ol:hover {
background: #0c5a9d;
border-color: #0c5a9d;
color: #fff;
}
.btn_ol a{
position: absolute;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
}
.btn_ol span {
display: inline-block;
position: relative;
font-size: 1.8rem;
margin: 0 auto;
transition: all 300ms ease-out;
will-change: transform;
font-weight: bold;
}
.btn_ol:hover span {
transform: translate3d(-1rem, 0, 0);
}
.btn_ol .ol_svg {
position: absolute;
margin: auto 5px;
top: 25%;
width: 1.1em;
right: -0.5rem;
opacity: 0;
transition: all 300ms ease-out;
will-change: right;
}
.btn_ol .ol_svg * {
stroke-width: 5;
}
.btn_ol:hover .ol_svg {
opacity: 1;
right: -3.5rem;
}
@media screen and (max-width: 720px) {
.btn_ol {
width: 100%;
padding: 2.3rem 1.1rem;
margin: 20px auto;
}
.btn_ol span {
line-height: 1.8rem;
font-size: 1.4rem;
}
.btn_ol .ol_svg {
top: 15%;
right: 0rem;
}
.btn_ol:hover .ol_svg {
right: -2.5rem;
}
}
In this CSS, we are trying to achieve the following - Text and svg files move when hovering - Color is reversed when hovering. - Open the link
There was no problem with the PC, but I found a problem with the SP site operation.
When operating on a tablet, it takes two clicks to jump the link. The first click keeps the hover on and the second click opens the window.
Apparently I was able to confirm that removing
.btn_ol:hover .ol_svg {
opacity: 1;
}
would open the link on the first tap, but I'm not sure how to implement it while keeping the SVG view.
please help me :)
You can try this code.
<div class="btn_ol">
<a href="http://google.com/" target="_blank">
<span>
Google<img src="../assets/images/common/icon_ol.svg" type="image/svg+xml">
</span>
</a>
</div>
Working for me.