Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 表单标记继承P标记对齐方式_Html - Fatal编程技术网

Html 表单标记继承P标记对齐方式

Html 表单标记继承P标记对齐方式,html,Html,是否有一种方法可以让表单标记从其正上方的p标记继承对齐方式 例如: <p style="text-align: center;"> <form... 继承关注点, 将信息从样式表传输到web文档的元素。 声明被定义到CSS规则中,涉及特定的HTML元素,称为选择器。嵌入(内联)到选择器中的元素通过CSS规则为其声明样式的元素会自动获得相同的样式。 在下面的示例中,段落元素包含继承其样式属性的元素。 段落元素的CSS规则是: p{字体系列:arial,圣衬线;颜色:蓝色} 然

是否有一种方法可以让表单标记从其正上方的p标记继承对齐方式

例如:

<p style="text-align: center;">
<form...

继承关注点,
将信息从样式表传输到web文档的元素。
声明被定义到CSS规则中,涉及特定的HTML元素,称为选择器。嵌入(内联)到选择器中的元素通过CSS规则为其声明样式的元素会自动获得相同的样式。
在下面的示例中,段落元素包含继承其样式属性的元素。
段落元素的CSS规则是:
p{字体系列:arial,圣衬线;颜色:蓝色}
然后,我们编写如下HTML代码:
继承问题
信息转型
来自样式表
添加到web文档的元素

这给了我们 内部元素b和i为其内容提供了父元素p的样式。这意味着它们从外部元素(即标记)继承样式。 大多数CSS属性从父元素继承到其子元素。 这一事实使我们在设计CSS样式表时能够从HTML文档的层次结构中的顶级元素开始,并将样式属性传递给嵌入元素(内部),避免为这些元素重写它们。 未继承的属性,如“显示”、“垂直对齐”和“边框”属性如果我们不通过设置值的样式规则定义声明,则在浏览器读取web文档时,这些属性将采用浏览器的默认值。
A
表单
是A,这意味着它不注意
文本对齐
。如果将
表单
设置为
显示:内联块
,则可以让它观察
p
标记的对齐方式

不过,从风格上讲:我建议不要在
p
标签中添加
form
标签,因为这不是真正的文本段落,是吗?除非你想要一个内联样式的
表单
:“你好,我的名字是uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

编辑2以澄清上述内容: 块级元素将像任何其他元素一样继承其父元素的属性(请参见下文:为什么
表单
不会继承
p
样式),但块本身不会根据
文本对齐
对齐,因为
文本对齐
定义了内联内容的对齐方式。也就是说,
文本中心内的
div
本身不会居中,除非它被标记为
内联块
内联
。但是内部
div
的内容将集中在该内部
div

编辑
看起来
form
不是
p
的有效子级,因此浏览器会将其从
p
中强制出来,从而不会继承任何样式(或识别类似
p>form
的选择器)。所以答案是,你不能让
表单
p
继承东西,因为它拒绝嵌套在
p

中。你能解决这个问题吗?当然,这不是真正的答案,是吗?我完全理解CSS和对齐。这不是我的问题。我不想将css添加到我的表单标签。。。。我的问题是,表单标记是否可以从p标记继承对齐方式?谢谢您的回答。我尝试了display:inline块,但它不起作用。作为旁注,我之所以问这个问题是因为我正在开发一个WordPress插件。WordPress中的默认文本编辑器使用p标记进行对齐,因此我无法控制该部分。我可以通过要求用户单独指定对齐方式并将其传递给div来轻松解决我的问题。但我一直在寻找一个更优雅的解决方案。您是在寻找对齐中心的
表单还是表单中的文本?表单中的文本和元素。@scottpaterson至少在Chrome中是这样的,它看起来像是浏览器拒绝将
表单
作为
p
的子项,并将其移到
p
之外,因此它不会继承任何内容。请参阅并检查滤芯。我已经为
p>表单
指定了一种红色,但这并没有得到应用,因为Chrome不接受
表单
p
的子项。这可能是您的问题。我建议WordPress插件(您正在创建短代码吗?)将对齐或类作为参数(例如
[plugin form align=“right”]
)并将其应用于表单本身。
<p style="text-align: center;">
<img...
Inheritance concerns,

transferring information from a style sheet to the elements of a web document.

Declarations are defined into CSS rules, concern specific HTML elements, which are known as selectors. Elements that are embedded (inline) into selectors-elements for whom the style has been declared through a CSS rule automatically get the same style.

In our example below, the paragraph element <p> contains elements that inherit its style properties.

The CSS rule for the paragraph element <p> is:     


  p  {font family: arial, san-serif;  color: blue}


We then write the HTML code as below:


 <p>Inheritance concerns
   <b>the information transition
      <i>from a style sheet</i>           
   </b>
   to the elements of a web document 
</p>


which gives us







The inner elements b and i give their contents the style of parent element p. This means that they inherit the style from their outer element which is the tag <p>.

Most of the CSS properties are inherited from the parent to its child elements.

This fact gives us the possibility when we design our CSS style sheet to start from the top level elements in the hierarchic structure of HTML document and pass the style properties to the embedded elements (inner) avoiding to rewrite them for these elements.

Properties which are not inherited such as display, vertical-align and the border properties if we do not define a declaration through a style rule that sets values to them, they will take the default values of the browser when it reads the web document.