6
버튼을 누군가가 그리는 것처럼 보이게하는 방법을 알아 내려고하고 있습니다.요소 경계선 그리기 (애니메이션)
가장 근접한 것은이 스 니펫입니다. 테두리 반경 세트로는 잘 작동하지 않지만 모두이 스 니펫입니다. 내가 SVG 파일을 사용하지 않도록하기 위해 노력하고있어
https://codepen.io/anon/pen/MbWagQ
<button class="draw">draw</button>
//Colors
$cyan: #60daaa;
$red: #f45e61;
// Basic styles
button {
background: none;
border: 0;
box-sizing: border-box;
color: $red;
font-size: inherit;
font-weight: 700;
padding: 1em 2em;
text-align: center;
margin: 20px;
// Required, since we're setting absolute on pseudo-elements
position: relative;
vertical-align: middle;
&::before,
&::after {
box-sizing: border-box;
content: '';
position: absolute;
width: 100%;
height: 100%;
}
}
.draw {
transition: color 0.25s;
border-radius: 7px;
&::before,
&::after {
border-radius: 7px;
border: 3px solid transparent; // Set border to invisible, so we don't see a 4px border on a 0x0 element before the transition starts
width: 0;
height: 0;
}
// This covers the top & right borders (expands right, then down)
&::before {
top: 0;
left: 0;
}
// And this the bottom & left borders (expands left, then up)
&::after {
bottom: 0;
right: 0;
}
&:hover {
color: $cyan;
}
// Hover styles
&:hover::before,
&:hover::after {
width: 100%;
height: 100%;
}
&:hover::before {
border-top-color: $cyan; // Make borders visible
border-right-color: $cyan;
transition:
width 0.25s ease-out, // Width expands first
height 0.25s ease-out 0.25s; // And then height
}
&:hover::after {
border-bottom-color: $cyan; // Make borders visible
border-left-color: $cyan;
transition:
border-color 0s ease-out 0.5s, // Wait for ::before to finish before showing border
width 0.25s ease-out 0.5s, // And then exanding width
height 0.25s ease-out 0.75s; // And finally height
}
}
(모서리를 시청), 바람직하게는 나는 순수 HTML & CSS에서이 작업을 수행하고 싶지만 자바 스크립트는 괜찮습니다.
'//'CSS에서 유효 주석 구문은 기술적으로가 아니라 몇 가지 이유 그것은/어디서나 작동하는 것 같습니다 :/ –
@Pamblam 종류의 무관 한 ... 어쨌든, 그것이 작동한다면, 그것은 "기술적으로 유효"면 중요합니까? – kanna
... 그리고 귀하의 질문은 무엇입니까? –