如何按外观顺序旋转(而非堆栈)垂直顺序的HTML块?
给定一个逻辑(可读的搜索引擎)HTML菜单,其中包含在< nav>
内包裹的无序列表菜单,从项目主页开始,然后以项目博客结尾。我在纯CSS和HTML中尝试了几件事,但无法实现我想要的东西。
”这是:
将整个垂直菜单与屏幕的左上边缘对齐。
中包含的列表项的数量和/或长度如何
无论< nav>
!!将每个带下划线的链接的可点击区域扩展到其整个蓝色块。
为了悬停并单击菜单项时易于使用。理想情况下,我们应该抛弃我的破碎开始,然后选择Flexbox CSS设计。
也许这为我们提供了更好的灵活性来实现这一目标。那将是一个奖励!
nav {
text-align:center;
transform: rotate(-90deg) translateX(-240px) translateY(-100px);
margin: 0;
top: 0px;
left: 0px;
position: absolute;
}
nav li{
display: inline-block;
background-color: blue;
height: 24px;
line-height: 24px;
vertical-align: middle;
margin: 5px auto;
padding: 1em;
}
nav li a{
color: #fff;
}
nav li a:hover{
background: black;
}
nav li.selected {
background-color: purple;
}
<nav>
<ul>
<li><a href="#">Home</a></li>
<li class="selected"><a href="#">Philosophy</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Blog</a></li>
</ul>
</nav>
Given a logical (search engine readable) HTML menu containing an unordered list menu wrapped inside a <nav>
, starting with item Home and ending with item Blog. I have tried several things in pure CSS and HTML but cannot achieve what I want.
https://jsfiddle.net/6zt3gfp4/
What I would like, is this:
Align the whole vertical menu to the top left edge of the screen, automatically.
Regardless of the number of and/or length of the list items contained in the<nav>
!!Expand the clickable area of each underlined link to its entire blue block.
For ease of use when hovering and clicking a menu item.Ideally we should leave my broken start behind and opt for a FlexBox CSS design.
Perhaps that gives us all better flexibility for achievng this. That would be a bonus!
nav {
text-align:center;
transform: rotate(-90deg) translateX(-240px) translateY(-100px);
margin: 0;
top: 0px;
left: 0px;
position: absolute;
}
nav li{
display: inline-block;
background-color: blue;
height: 24px;
line-height: 24px;
vertical-align: middle;
margin: 5px auto;
padding: 1em;
}
nav li a{
color: #fff;
}
nav li a:hover{
background: black;
}
nav li.selected {
background-color: purple;
}
<nav>
<ul>
<li><a href="#">Home</a></li>
<li class="selected"><a href="#">Philosophy</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Blog</a></li>
</ul>
</nav>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转型不要玩很多。然后使用写作模式然后将应用于
li
的样式移至a
以使链接区域更大。Don't play a lot with transformation. Use writing-mode then move the style applied to
li
toa
to make the link area bigger.