为什么text-align没有效果_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:13:30
Original
1423 people have browsed it

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/css" href="style.css"?><books>    <book>        <bookname>Java Web</bookname>        <author>Wang</author>        <publishing>QingHua</publishing>        <company>MingRi</company>        <ISBN>7-302-21033-7</ISBN>        <price unit="RMB">69.80</price>        <url>![CDATA[http://www.mingribook].com/bookinfo.php?id=227&sid=4]</url>    </book>    <book>        <bookname>DBMS</bookname>        <author>Wang</author>        <publishing>RenMing</publishing>        <company>MingRi</company>        <ISBN>7-115-14689-6</ISBN>        <price unit="RMB">49.80</price>        <url>![CDATA[http://www.mingribook].com/bookinfo.php?id=208&sid=11]</url>    </book></books>
Copy after login

author,pulishing,company,ISBN,price{    text-align: center;    width: 18%;}
Copy after login

把text-align改成 float:left 反而实现效果


回复讨论(解决方案)

这是什么,在浏览器上看xml?不被识别的html标签好像都会解析为内联元素,而普通内联元素是没有宽度属性的,没有宽度当然内部文本就不会居中,加个background背景色看下就明白了。
加float:left ;会以块状元素解析,块状元素是可以有宽度的,所以就有效果了。
同样的也可以使用display:inline-block;

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template