我有我的投资组合的首页布局,我试图实现一些垂直文本。右边的部分(蓝色)是我的名字将垂直书写的地方。当我尝试通过css转换旋转文本时,它会在滚动时搞砸布局。所以我很难过。您必须将大小增加到整页才能正确查看布局。名称应该延伸蓝色容器的全长。 https://codepen.io/marti2221/pen/BdrdZJ
<div class="container">
<div class="left">
<div class="svg-container">
<div class="svg-logo"></div>
</div>
<div class="question-container">
<p>WHO AM I?</p>
<p>WHAT DO I DO?</p>
</div>
</div>
<div class="middle">
<div class="top">
<nav>
<a>Link1</a>
<a>Link2</a>
<a>Link3</a>
<a>Link4</a>
</nav>
</div>
<div class="bottom">
<h1>Im an extremely</br> passionate User</br> Interface Design</br> +
Developer</h1>
</div>
</div>
<div class="right">
<h1></h1>
</div>
</div>
.container{
display: flex;
height: 100vh;
background: black;
}
.left{
display: flex;
flex: 1;
background: gray;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.svg-container{
display: flex;
flex-grow: 1;
background: yellow;
width: 100%;
justify-content: center;
}
.svg-logo{
height: 100px;
width: 200px;
background: orange;
}
.question-container{
display: flex;
flex-grow: 1;
background: green;
width: 100%;
flex-direction: column;
justify-content: flex-end;
align-items: flex-end;
}
p{
display: flex;
margin-right: 10px;
}
.middle{
display: flex;
flex: 3;
background: red;
flex-direction: column;
}
.top{
display: flex;
flex: 1;
background: aqua;
}
nav{
display: flex;
flex-direction: column;
margin: 65px 0 0 65px;
}
a:before {
content: '\2014';
position: absolute;
margin-left: -40px;
}
a{
margin: 10px 0 10px 0;
font-size: 24px;
}
.bottom{
display: inline-flex;
flex: 1;
background: brown;
align-items: flex-start;
}
h1{
margin-left: 25px;
font-size: 55px;
}
.right{
display: flex;
flex: .5;
background: blue;
}
.name{
transform: rotate(90deg);
}
答案 0 :(得分:2)
sideways-lr
单独(没有transform
)会解决它,但截至今天只有Firefox支持它。
将writing-mode: vertical-lr;
与transform: rotate
结合使用,它会表现得更符合您的期望
Stack snippet
.container{
display: flex;
height: 100vh;
background: black;
}
.left{
display: flex;
flex: 1;
background: gray;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.svg-container{
display: flex;
flex-grow: 1;
background: yellow;
width: 100%;
justify-content: center;
}
.svg-logo{
height: 100px;
width: 200px;
background: orange;
}
.question-container{
display: flex;
flex-grow: 1;
background: green;
width: 100%;
flex-direction: column;
justify-content: flex-end;
align-items: flex-end;
}
p{
display: flex;
margin-right: 10px;
}
.middle{
display: flex;
flex: 3;
background: red;
flex-direction: column;
}
.top{
display: flex;
flex: 1;
background: aqua;
}
nav{
display: flex;
flex-direction: column;
margin: 65px 0 0 65px;
}
a:before {
content: '\2014';
position: absolute;
margin-left: -40px;
}
a{
margin: 10px 0 10px 0;
font-size: 24px;
}
.bottom{
display: inline-flex;
flex: 1;
background: brown;
align-items: flex-start;
}
h1{
margin-left: 25px;
font-size: 55px;
}
.right{
display: flex;
flex: .2;
background: blue;
flex-direction: column;
justify-content: center;
}
.name{
display: flex;
transform: rotate(-180deg); /* changed */
background: pink;
writing-mode: tb-lr; /* for IE */
writing-mode: vertical-lr; /* added */
}
<div class="container">
<div class="left">
<div class="svg-container">
<div class="svg-logo"></div>
</div>
<div class="question-container">
<p>WHO AM I?</p>
<p>WHAT DO I DO?</p>
</div>
</div>
<div class="middle">
<div class="top">
<nav>
<a>Link1</a>
<a>Link2</a>
<a>Link3</a>
<a>Link4</a>
</nav>
</div>
<div class="bottom">
<h1>Im an extremely</br> passionate User</br> Interface Design</br> + Developer</h1>
</div>
</div>
<div class="right">
<h2 class="name">Travis Martin</h2>
</div>
</div>