英文:
How can i get my transition working because nothing works?
问题
I tried multiple things like changing the transition duration by a transition all with the duration and others but it never worked. Send help
我尝试了多种方法,例如通过使用带有持续时间的 transition all 来更改过渡持续时间等,但从未奏效。发送帮助
Here's the codepen: https://codepen.io/LeLicorne/pen/ZEqpwPJ
这是 CodePen 链接:https://codepen.io/LeLicorne/pen/ZEqpwPJ
:root {
--homeBookmark-after-left: 0px;
--homeBookmark-after-top: 0px;
--homeBookmark-Color: #9747FF;
--skillsBookmark-Color: #0079D0;
--workBookmark-Color: #00EA25;
--contactBookmark-Color: #F05600;
}
* {
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
color: black;
box-sizing: border-box;
}
body {
background-color: #222222;
}
header {
width: 100%;
height: auto;
display: flex;
flex-direction: row;
justify-content: start;
align-items: start;
position: fixed;
}
header nav {
width: 33%;
height: 100%;
display: flex;
flex-direction: row;
gap: 50px;
justify-content: center;
align-items: start;
}
header nav a {
background-color: aliceblue;
padding: 10px;
transform: translateX(-50%);
display: flex;
flex-direction: row;
justify-content: center;
align-items: end;
transition-duration: 250ms;
}
header nav a:hover {
height: 70px;
}
#homeBookmark {
background-color: var(--homeBookmark-Color);
}
#skillsBookmark {
background-color: var(--skillsBookmark-Color);
}
#workBookmark {
background-color: var(--workBookmark-Color);
}
#contactBookmark {
background-color: var(--contactBookmark-Color);
}
header nav a i {
font-size: 26px;
}
<header>
<nav>
<a href="#" id="homeBookmark"><i class="bi bi-house-fill"></i></a>
<a href="#" id="skillsBookmark"><i class="bi bi-pie-chart-fill"></i></a>
<a href="#" id="workBookmark"><i class="bi bi-folder-fill"></i></a>
<a href="#" id="contactBookmark"><i class="bi bi-person-lines-fill"></i></a>
</nav>
</header>
I hope this helps! 我希望这有所帮助!
英文:
I tried multiple things like changing the transition duration by a transition all with the duration and others but it never worked. Send help
Here's the codepen: https://codepen.io/LeLicorne/pen/ZEqpwPJ
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
:root {
--homeBookmark-after-left: 0px;
--homeBookmark-after-top: 0px;
--homeBookmark-Color: #9747FF;
--skillsBookmark-Color: #0079D0;
--workBookmark-Color: #00EA25;
--contactBookmark-Color: #F05600;
}
* {
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
color: black;
box-sizing: border-box;
}
body {
background-color: #222222;
}
header {
width: 100%;
height: auto;
display: flex;
flex-direction: row;
justify-content: start;
align-items: start;
position: fixed;
}
header nav {
width: 33%;
height: 100%;
display: flex;
flex-direction: row;
gap: 50px;
justify-content: center;
align-items: start;
}
header nav a {
background-color: aliceblue;
padding: 10px;
transform: translateX(-50%);
display: flex;
flex-direction: row;
justify-content: center;
align-items: end;
transition-duration: 250ms;
}
header nav a:hover {
height: 70px;
}
/* #homeBookmark::after{ it s the 'a'
content: '';
position: absolute;
height: 0;
width: 0;
left: var(--homeBookmark-after-left);
top: var(--homeBookmark-after-top);
background: transparent;
border-right: 23px solid transparent;
border-left: 23px solid transparent;
border-top: 15px solid purple;
} */
#homeBookmark {
background-color: var(--homeBookmark-Color);
}
#skillsBookmark {
background-color: var(--skillsBookmark-Color);
}
#workBookmark {
background-color: var(--workBookmark-Color);
}
#contactBookmark {
background-color: var(--contactBookmark-Color);
}
header nav a i {
font-size: 26px;
}
<!-- language: lang-html -->
<header>
<nav>
<a href="#" id="homeBookmark"><i class="bi bi-house-fill"></i></a>
<a href="#" id="skillsBookmark"><!-- <i class="bi bi-wrench-adjustable-circle-fill"></i> --><i class="bi bi-pie-chart-fill"></i></a>
<a href="#" id="workBookmark"><i class="bi bi-folder-fill"></i></a>
<a href="#" id="contactBookmark"><i class="bi bi-person-lines-fill"></i></a>
</nav>
</header>
<!-- end snippet -->
tried changing transition-duration to transition all 250ms and the other things of needed
and also i tried with the -webkit- -moz- and -ms- transition and didn't work
答案1
得分: 0
以下是您要翻译的内容:
根据我的评论提到,您需要添加:
transition: all .25s ease
- 因为您需要transition
属性。您也可以只针对height
值进行目标设置,因为那是您要更改的内容:transition: height 250ms ease
- 您需要为主要的
header nav a
添加一个height
属性。您需要确定正确的值。我使用10px
作为占位符。
英文:
As mentioned in my comment, you need to add:
transition: all .25s ease
- since you need thetransition
property. You could also target just theheight
value, since that's what you're changing:transition: height 250ms ease
- You need to add a
height
property to the mainheader nav a
. You'll have to determine the correct value. I used10px
as a placeholder.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
:root {
--homeBookmark-after-left: 0px;
--homeBookmark-after-top: 0px;
--homeBookmark-Color: #9747FF;
--skillsBookmark-Color: #0079D0;
--workBookmark-Color: #00EA25;
--contactBookmark-Color: #F05600;
}
* {
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
color: black;
box-sizing: border-box;
}
body {
background-color: #222222;
}
header {
width: 100%;
height: auto;
display: flex;
flex-direction: row;
justify-content: start;
align-items: start;
position: fixed;
}
header nav {
width: 33%;
height: 100%;
display: flex;
flex-direction: row;
gap: 50px;
justify-content: center;
align-items: start;
}
header nav a {
background-color: aliceblue;
padding: 10px;
transform: translateX(-50%);
display: flex;
flex-direction: row;
justify-content: center;
align-items: end;
transition: all 250ms ease;
height: 10px;
}
header nav a:hover {
height: 70px;
}
/* #homeBookmark::after{ it s the 'a'
content: '';
position: absolute;
height: 0;
width: 0;
left: var(--homeBookmark-after-left);
top: var(--homeBookmark-after-top);
background: transparent;
border-right: 23px solid transparent;
border-left: 23px solid transparent;
border-top: 15px solid purple;
} */
#homeBookmark {
background-color: var(--homeBookmark-Color);
}
#skillsBookmark {
background-color: var(--skillsBookmark-Color);
}
#workBookmark {
background-color: var(--workBookmark-Color);
}
#contactBookmark {
background-color: var(--contactBookmark-Color);
}
header nav a i {
font-size: 26px;
}
<!-- language: lang-html -->
<header>
<nav>
<a href="#" id="homeBookmark"><i class="bi bi-house-fill"></i></a>
<a href="#" id="skillsBookmark"><i class="bi bi-pie-chart-fill"></i></a>
<a href="#" id="workBookmark"><i class="bi bi-folder-fill"></i></a>
<a href="#" id="contactBookmark"><i class="bi bi-person-lines-fill"></i></a>
</nav>
</header>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论