首页 \ 问答 \ 如何显示HTML
作为内联元素?(How to display HTML as inline element?)

如何显示HTML 作为内联元素?(How to display HTML as inline element?)

这可能是一个基本的html / css问题...

我有一个简单的一键形式,我想在段落文本内部显示。

<p>Read this sentence 
     <form style='display:inline;'>
     <input style='display:inline;' 
            type='submit' 
            value='or push this button'/>
     </form>.
</p>

即使表单有style = display:inline属性,我在表单之前得到一个换行符。 有没有办法摆脱它?

可以在<p>显示元素吗?


This is probably a basic html/css question...

I have a simple one-button form that I would like to display inline inside paragraph text.

<p>Read this sentence 
     <form style='display:inline;'>
     <input style='display:inline;' 
            type='submit' 
            value='or push this button'/>
     </form>.
</p>

Even though form has style=display:inline attribute, I get a linebreak before the form. Is there a way to get rid of it?

Can form elements appear inside <p>?


原文:https://stackoverflow.com/questions/1106720
更新时间:2023-05-20 20:05

最满意答案

你可以使用css 绑定 。 它可以用两种方法。 使用动态类(或类列表):

<li data-bind="css: name"></li>

或者使用与真实/伪造值绑定的各个类来指示是否应该从元素中添加/删除它们:

<li data-bind="css: { classOne: hasClassOne, classTwo: hasClassTwo }"></li>

You can use the css binding. It can be used two ways. Either with a dynamic class (or list of classes):

<li data-bind="css: name"></li>

or with individual classes bound against truthy/falsy values to indicate whether that are should be added/removed from the element:

<li data-bind="css: { classOne: hasClassOne, classTwo: hasClassTwo }"></li>

相关问答

更多
  • 事实证明我犯了一个菜鸟错误。 这是工作代码:
    This plan is a draft!
    由于变量是由knockout组成的,因此需要PlanStateName上的括号来访问基础数据。 So it turns out I made a rookie mistake. Here's the working code: