如何在 HTML 中创建一个矩形并在其上放置一些文本?

hel*_*llo 1 html html5-canvas css-shapes

我想在 html 中创建一个矩形并在上面放置一些文本。当单击该矩形时,它应该重定向到另一个页面..有任何指针吗?

jbu*_*483 5

您应该使用带有显示设置的 a 标签:

a {
  display: inline-block;
  height: 50px; /*sets height of element*/
  background: cornflowerblue; /*sets the background of this element (here a solid colour)*/
  transition: all 0.6s; /*sets a transition (for hover effect)*/
  padding-left: 20px; /*sets 'padding'*/
  padding-right: 20px; /*sets 'padding'*/
  line-height: 50px; /*for this, it sets vertical alignment*/
}
a:hover {
  background: tomato; /*sets background colour*/
}
Run Code Online (Sandbox Code Playgroud)
<a href="#">Some Text</a>
Run Code Online (Sandbox Code Playgroud)

在您的href属性中,您应该放置指向下一页的链接:

<a href="/Home/NextPageDirectory">Link Text</a>
Run Code Online (Sandbox Code Playgroud)