简体   繁体   English

HTML显示数据为空白时如何使forms保持原位

[英]How to make forms stay in place when HTML display data is blank

I'm trying to make a form field stay in place whenever the HTML display data part is blank.每当 HTML 显示数据部分为空白时,我都会尝试使表单字段保持不变。 The form field does stay in place whenever the display data part is filled in, but when it is blank, the form field moves upward and indents slightly to the right.每当填写显示数据部分时,表单域确实会保持原位,但是当它为空白时,表单域会向上移动并略微向右缩进。 I'm trying to code it in a way that when it is blank, the entire form field does not move upward, and does not indent slightly to the right.我试图以这样一种方式对其进行编码,当它为空白时,整个表单域不会向上移动,也不会略微向右缩进。

My code looks like this:我的代码如下所示:

          <h2 :title="option.ID">
            <image/>
            {{ option.Name }}
          </h2>

            <div class="row">
             <label class="bold">Option Name</label>
            </div>
              <div class="optio ">
                  <input
                    v-model="option.Name"
                    :disabled="isDisabled(option)"
                  >
              </div>
            </div>

Any idea how to do this?知道怎么做吗? Thank you!谢谢!

Your form probably moves up when the input is empty because of the rendering of option.Name in the <h2> .由于在<h2>中呈现 option.Name ,当输入为空时,您的表单可能会向上移动。 However, this would probably depend on the size of the image contained in it.但是,这可能取决于其中包含的图像的大小。

Could you try to add some dummy text next to {{ option.Name }} and see if the problem persists?您能否尝试在{{ option.Name }}旁边添加一些虚拟文本,看看问题是否仍然存在?

for instance:例如:

<h2 :title="option.ID">
  <image
    id="photo"
    alt="`photo picture`"
    title="option image"
    class="image" />
    {{ option.Name }} dummy text
</h2>

If the form doesn't move anymore, you can think of setting setting the height of the h2 in CSS, or force the rendering of some text when option.Name is undefined:如果窗体不再移动,可以考虑在 CSS 中设置 h2 的高度,或者在option.Name未定义时强制渲染一些文本:

<h2 :title="option.ID">
  <image
    id="photo"
    alt="`photo picture`"
    title="option image"
    class="image" />
    {{ option.Name || 'placeholder' }} dummy text
</h2>

Here, placeholder can be whatever you want, even a space在这里,占位符可以是任何你想要的,甚至是一个空格

暂无
暂无

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

相关问题 滚动时使html元素保持原位 - Make html element stay in place when scrolled past 隐藏另一个 div 时如何使 div 保持原位? - How to make div stay in place when another div is hidden? 如何使垂直导航栏的文本在打开时保持在同一位置? - How do I make my vertical navbar's text stay at the same place when it opens? 如果名称较长,如何使可单击按钮保持在原位 - How to make clickable buttons stay in place if they have long names 如何使 Chart.js 条形图保持原位 - How to make a Chart.js Bar chart stay in its place 页面刷新后如何使拖放保持在放置的位置 - How to make drag drop stay at dropped place after page refresh 我如何使导航系统为每个项目显示不同的表单,但在同一位置显示不同的导航项目? - how would I make a navigation system that display a different forms for each item different navigation item in the same place? 当左div向下滑动时,右div被推到其下方。 如何使他们留在正确的地方? - When the left div slides down, the right div is pushed below it. How can I make them stay in the correct place? 当您单击或停止使用Javascript进行鼠标悬停时,如何使CSS on-hover内容保持不变? - How can you make CSS on-hover content stay in place when you click or stop hovering using Javascript? 如何使可拖动元素在放下时保持在新位置(HTML5 不是 jQuery)? - How to make a draggable element stay at the new position when dropped (HTML5 not jQuery)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM