Set writing mode / text direction bottom to top
I can't find a solution to make the green elements start at the bottom right of the container, like in right image ("Need").
Does CSS provide a way to align/orient elements from the bottom?
"Default" and "Need" element's location illustrated.
SNIPPET
.cnt {
width:200px;
height:300px;
border:1px solid green;
text-align:center;
display: table-cell;
vertical-align: bottom;
}
.itm {
transform: translate(0px, 0px) scale(1);
display: inline-block;
padding:10px;
width:20px;
margin:10px;
background: green;
color: white;
transition:transform 0.5s;
}
.itm:hover {
transform: translate(0px, -3px) scale(1.1);
}
<div class="cnt">
<div class="itm">1</div>
<div class="itm">2</div>
<div class="itm">3</div>
<div class="itm">4</div>
<div class="itm">5</div>
<div class="itm">6</div>
<div class="itm">7</div>
<div class="itm">8</div>
</div>
Does CSS provide a way to align/orient elements from the bottom?
Surprisingly, in horizontal writing mode, it doesn't appear so.
There are various properties, including writing-mode
, direction
, text-orientation
and flex-direction
, that allow you to re-arrange the flow of content.
But none of them appear to allow the laying out of content in a horizontal writing mode starting from the bottom right. Maybe somebody could correct me on this.
In the meanwhile, here's a hack (pure CSS):
.cnt {
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
align-items: flex-start;
align-content: flex-start;
justify-content: center;
text-align: center;
width: 200px;
height: 300px;
border: 1px solid green;
transform: scaleY(-1);
}
.itm {
padding: 10px;
width: 20px;
margin: 10px;
background: green;
color: white;
transform: translate(0px, 0px) scaleY(-1) scaleX(1);
transition: transform 0.5s;
}
.itm:hover {
transform: translate(0px, -3px) scaleY(-1.1) scaleX(1.1);
}
<div class="cnt">
<div class="itm">8</div>
<div class="itm">7</div>
<div class="itm">6</div>
<div class="itm">5</div>
<div class="itm">4</div>
<div class="itm">3</div>
<div class="itm">2</div>
<div class="itm">1</div>
</div>
如果您可以在源代码中反转itms的顺序,那很容易。
.cnt {
width:200px;
height:300px;
border:1px solid green;
text-align:center;
display: table-cell;
vertical-align: top;
transform:rotate(180deg);
}
.itm {
display: inline-block;
padding:10px;
width:20px;
margin:10px;
background: green;
color: white;
transform:rotate(180deg);
}
<div class="cnt">
<div class="itm">8</div>
<div class="itm">7</div>
<div class="itm">6</div>
<div class="itm">5</div>
<div class="itm">4</div>
<div class="itm">3</div>
<div class="itm">2</div>
<div class="itm">1</div>
</div>
I know this isn't exactly it, but it's the closest I could get with a pure CSS solution. It's pretty ugly, though. Posting more so that others may see it and use it to get to the correct answer.
.cnt {
width:200px;
height:300px;
border:1px solid green;
text-align:center;
display: table-cell;
vertical-align: bottom;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
align-content: flex-end;
}
.itm {
transform: translate(0px, 0px) scale(1);
display: inline-block;
padding:10px;
width:20px;
height: 20px;
margin:10px;
background: green;
color: white;
transition:transform 0.5s;
}
.itm:hover {
transform: translate(0px, -3px) scale(1.1);
}
.itm:nth-child(1) {
order: 8;
}
.itm:nth-child(2) {
order: 7;
}
.itm:nth-child(3) {
order: 6;
}
.itm:nth-child(4) {
order: 5;
}
.itm:nth-child(5) {
order: 4;
}
.itm:nth-child(6) {
order: 3;
}
.itm:nth-child(7) {
order: 2;
}
.itm:nth-child(8) {
order: 1;
}
<div class="cnt">
<div class="itm">1</div>
<div class="itm">2</div>
<div class="itm">3</div>
<div class="itm">4</div>
<div class="itm">5</div>
<div class="itm">6</div>
<div class="itm">7</div>
<div class="itm">8</div>
</div>
链接地址: http://www.djcxy.com/p/93724.html
上一篇: 不能执行命令,而是转到换行符
下一篇: 将写入模式/文字方向从下至上设置