나는 링크에 : before 속성에 '>'를 추가하고 있지만 : hover 효과를 적용하면 스타일도 취 text-decoration: underline;
하므로 추가 된 내용에 효과를 적용하지 않아야합니다. : before, 나는이 엉을 해결하려고했습니다. 옵션
a:before {
content: '> ';
position: relative;
display: inline-block;
margin-right: 5px;
pointer-events: none;
}
a:before:hover {
content: '>';
pointer-events: none;
}
a:before:hover {
text-decoration:none;
}
그러나 아무것도 작동하지 않습니다.
이것은 링크가 호버로 작동하는 방식입니다.
여기 내 코드의 예입니다, 구조, <a>
내부는 <p>
내용이 텍스트 편집기에서이기 때문이다
.super {
color: rgb(40, 40, 40);
background-color: rgb(239, 239, 239);
margin-bottom: 35px;
padding: 10px;
}
p {
position: relative;
word-break: break-word;
font-size: 17px;
padding: 0px;
}
a {
left: 0px;
display: flex;
position: relative;
left: 0;
display: flex;
text-decoration: none;
}
a::before {
content: '> ';
position: relative;
display: inline-block;
margin-right: 5px;
}
a:hover{
text-decoration:underline;
}
<div class='super'>
<p>
<a href='https://google.com' target='_blanck'>Example to link</a>
</p>
</div>
작동하지 않을 경우 중지되는 코드에는 두 가지가 있습니다.
display:flex
:hover:before
있지만 display:flex
어쨌든 작동하지 않기 때문에 그것은 중요하지 않습니다 .a
요소에 대한 기본 표시를 사용하면 텍스트 밑줄은 :before
의사 요소를 사용하여 추가 된 콘텐츠에 영향을주지 않습니다 . 그러나 사용 display:flex
이 표시되고 텍스트 밑줄에 추가 된 내용에 추가되도록하는 방법을 변경 a:before
뿐만 아니라 링크 텍스트 :
작업 예 :
업데이트 : 당신의 충족시키기 위해 새로운 긴 링크를 들여 쓰기의 새로운 요구를 하고 HTML을 변경할 수없는.
.super {
color: rgb(40, 40, 40);
background-color: rgb(239, 239, 239);
margin-bottom: 35px;
padding: 10px;
}
p {
position: relative;
word-break: break-word;
font-size: 17px;
padding: 0px;
}
a {
position: relative;
text-decoration: none;
display: block;
padding-left: 15px;
}
a:before {
content: '>';
position:absolute;
left:0;
top: 0;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
a:hover:before{
text-decoration:none;
}
<div class='super'>
<p>
<a href='https://google.com' target='_blanck'><span>This is a very long link This is a very long link This is a very long link This is a very long link This is a very long link This is a very long link This is a very long link This is a very long link This is a very long link</span></a>
</p>
</div>
또한 FYI, :hover
and :before
함께 사용하는 올바른 방법 은 :hover:before
이지만이 경우 display:flex
아래에서 볼 수 있듯이 사용할 때 차이가 없습니다 .
올바른 CSS a:hover:before
를 사용하는 예제 display:flex
(보시다시피 작동하지 않음) :
.super {
color: rgb(40, 40, 40);
background-color: rgb(239, 239, 239);
margin-bottom: 35px;
padding: 10px;
}
p {
position: relative;
word-break: break-word;
font-size: 17px;
padding: 0px;
}
a {
left: 0px;
display:flex;
position: relative;
text-decoration: none;
}
a::before {
content: '> ';
position: relative;
display: inline-block;
margin-right: 5px;
text-decoration:none!important;
}
a:hover{
text-decoration:underline;
}
a:hover::before {
text-decoration:none!important;
}
<div class='super'>
<p>
<a href='https://google.com' target='_blanck'>Example to link</a>
</p>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다