简体   繁体   English

整个div作为链接href,但不输入文本

[英]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无效有两个原因:

  1. <a> is an inline element and as such can't contain block level elements as <div> <a>是一个内联元素,因此不能包含像<div>这样的块级元素
  2. by specification <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/

如何拥有一个整体<div>包含带有 href 的链接</div><div id="text_translate"><p>我正在尝试将“signup.php”的&lt;a href&gt;链接更改为 go 从NOW的单词到整个&lt;div&gt; ,因此当用户将鼠标悬停在该 div 内的任何内容上时,该链接将起作用:</p><p> <strong>HTML:</strong></p><pre> &lt;div class="row"&gt; &lt;div class="grid-full containerHomepage"&gt; &lt;div class="centered"&gt;SIGN UP TO HEAD SMART&lt;a class="noDecoration brain" href="signup.php"&gt; NOW&lt;/a&gt; &lt;img src="images/HeadSmart.png" width="50" height="60"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</pre></div> - How to have a whole <div> contain a link with a href

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何拥有一个整体<div>包含带有 href 的链接</div><div id="text_translate"><p>我正在尝试将“signup.php”的&lt;a href&gt;链接更改为 go 从NOW的单词到整个&lt;div&gt; ,因此当用户将鼠标悬停在该 div 内的任何内容上时,该链接将起作用:</p><p> <strong>HTML:</strong></p><pre> &lt;div class="row"&gt; &lt;div class="grid-full containerHomepage"&gt; &lt;div class="centered"&gt;SIGN UP TO HEAD SMART&lt;a class="noDecoration brain" href="signup.php"&gt; NOW&lt;/a&gt; &lt;img src="images/HeadSmart.png" width="50" height="60"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</pre></div> - How to have a whole <div> contain a link with a href Href 仅在单击 div 文本而不是整个 div 时有效 - Href only works when clicking on div text and not whole div href链接并在相同的输入文本中进行编辑 - href link and edit in same input text 如何让整个输入文本框充满整个div - How to make the whole input text box full of the whole div <div>链接打不开 - <a href=link><div></a> link not woking 在haml中将div或div作为href - div into link or div as href in haml 链接整个DIV - Link a whole DIV 使用文本输入值即时更改链接href属性 - Change link href attribute on the fly with text input value 如何将输入(文本)值添加到链接的href属性中 - How to add input(text) value into the href attribute of a link 使用定位点将href链接到下一个div - Link href to the next div with anchorpoint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM