[英]ASP.NET razor pages menu
I am working on a project in ASP.NET Core with Razor pages and I have a menu that has a picture and a link.我正在使用 ASP.NET 内核和 Razor 页面开发一个项目,并且我有一个包含图片和链接的菜单。 I am trying to make all the area of the
li
clickable as a link.我正在尝试使
li
的所有区域都可以作为链接点击。
Here is the code for my menu in the view markup:这是视图标记中我的菜单的代码:
<div id="myMenu">
<ul>
<li>
<img src=""/>
<a asp-page="/Index"><h5>Index</h5></a>
</li>
<li>
<img src=""/>
<a asp-page="/Index2"><h5>Index2</h5></a>
</li>
<li>
<img src=""/>
<a asp-page="/Index3"><h5>Index3</h5></a>
</li>
</ul>
</div>
In my CSS, I tried:在我的 CSS 中,我尝试过:
#myMenu ul li a {
display: inline-block;
width: 100%;
}
ul {
display: flex;
}
li {
height: 90px;
}
The problem is that I can only click on the link, not on the full area of the li
.问题是我只能点击链接,而不是
li
的整个区域。 Is there any way I can do this?有什么办法可以做到这一点吗?
If i understand your question correctly, you can put all the content you want to be clickable inside the <a>
tag.如果我正确理解您的问题,您可以将所有您希望可点击的内容放在
<a>
标记内。
<a href="#">
<img src="#"/>
<h5>Title</h5>
</a>
Heres an example:这是一个例子:
https://codepen.io/fernandesdiegod/pen/VweNXPB https://codepen.io/fernandesdiegod/pen/VweNXPB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.