CSS에서 배경 이미지를 어둡게 하고 마우스로 강조 표시
4265 단어 CSS
배경 이미지 먼저 추가
코드
<a href="#">
<div class="menu">
<div class="box">
ここに文章があったり。
</div>
</div>
</a>
먼저 CSS를 통해 배경을 어둡게 만듭니다.CSS 코드
.menu {
height: 100px;
background: url(fruits.jpg) center no-repeat;
background-size: cover;
position: relative;
height:100%;
}
.box {
position: absolute;
width: 100%;
top: 45%;
text-align: center;
color: #FFF;
}
배경 이미지를 어둡게 만들기
배경 요소에 CSS에서 어두워진 요소 이미지 추가하기
.menu::before{
background-color: rgba(0,0,0,0.3);
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
content: ' ';
}
마우스가 지나가자마자 밝아졌다
삽입된 CSS만 열기
a:hover .menu::before{
background-color: rgba(0,0,0,0);
}
Reference
이 문제에 관하여(CSS에서 배경 이미지를 어둡게 하고 마우스로 강조 표시), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/chii/items/5c4eeb250a26300fc955텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)