[英]whole div as link href but not input text
How I can make it so that whole div is a link href, but not input text, which is in inside div? 我怎样才能使整个div是一个链接href,而不是输入文本,它位于div内部? This is possible? 这个有可能? In this situation I can't type in input. 在这种情况下,我无法输入输入。
<a href="@Url.Action("Zadania", "Admin", new { id = item.Id })">
<div id="order">
<div>
<b>Zleceniodawca:</b> @item.CustomerName
<b>Typ zlecenia:</b> @item.OrderType
</div>
<b>Postęp pracy: </b><input type="text" name="progress" value="@item.ProgressWork"/>
</div>
</a>
Your current HTML is invalid for 2 reasons: 您当前的HTML无效有两个原因:
<a>
is an inline element and as such can't contain block level elements as <div>
<a>
是一个内联元素,因此不能包含像<div>
这样的块级元素 <a>
tag is not allowed to contain interactive content: 根据规范, <a>
标签不允许包含交互式内容: Content model: Transparent , but there must be no interactive content descendant. 内容模型: 透明 ,但必须没有交互式内容后代。
Move the input
outside of the a
tag and position it absolutely on top of the link. 移动input
的外a
标签,并将其链接的绝对顶部位置。 Everything will still be inside the link, except that the input is now on top of the link and is normally clickable: 除了输入现在位于链接顶部并且通常可以单击之外,所有内容仍将在链接内部:
<div id="order">
<a href="@Url.Action(" Zadania ", "Admin ", new { id = item.Id })">
<span>
<b>Zleceniodawca:</b> @item.CustomerName
<b>Typ zlecenia:</b> @item.OrderType
</span>
<b>Postęp pracy: </b>
</a>
<input type="text" name="progress" value="@item.ProgressWork" />
</div>
#order {
position:relative;
background:f2f2f2;
border:1px solid #000;
}
#order > a {
display:block;
padding:20px;
text-align:center;
}
#order input {
position:absolute;
top:20px;
left:50%;
width:100px;
margin-left:-50px;
}
Example: http://jsfiddle.net/jFL6R/ 示例: http : //jsfiddle.net/jFL6R/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.