Home >Web Front-end >HTML Tutorial >为什么text-align没有效果_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-21 09:13:301435browse

<?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>

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

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


回复讨论(解决方案)

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

Statement:
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