居中图像不起作用

时间:2017-07-19 11:31:28

标签: css image

<html>
    <head>
    <style type="tex/css">
	body{
		font-family: Georgia, "Times New Roman", serif;
		color: #665544;
	}
	img.align-center {
		display:block;
		margin:0px auto;
	}
	img.medium{
		width:250px;
		height:250px;
	}
    </style>
    </head>
    <body>
	<p><img src="../../Images/magnolia-medium.jpg" alt="Magnolia" class="align-
    center medium" /><b><i>Magnolia</i></b> is a large genus that contains over 
    200 flowering plant species. It is named after French botanist Pierre Magnol 
     and, having evolved before bees appeared, the flowers were developed to 
     encourage pollination by beetle.</p>
    </body>
   </html>

图像应居中但我看到窗口左侧的图像。有什么问题????

3 个答案:

答案 0 :(得分:2)

1) int

<style type="tex/css">

2)更改赞:

                 ^----------------text no tex

&#13;
&#13;
p {
  margin:0px auto;
  width: 250px;
}

img.medium {
  width: 100%;
}
&#13;
 body {
   font-family: Georgia, "Times New Roman", serif;
   color: #665544;
 }

 p {
   margin:0px auto;
   width: 250px;
 }

 img.medium {
   width: 100%;
 }
&#13;
&#13;
&#13;

答案 1 :(得分:1)

编辑:

代码中align-center之间有空格。删除空格的结果如下所示。

body {
  font-family: Georgia, "Times New Roman", serif;
  color: #665544;
}

.align-center {
  display: block;
  margin: 0 auto;
}

.medium {
  width: 250px;
  height: 250px;
}
<p><img src="http://placehold.it/200" alt="Magnolia" class="align-center medium" />
<b><i>Magnolia</i></b> is a large genus that contains over 200 flowering plant species. It is named after French botanist Pierre Magnol and, having evolved before bees appeared, the flowers were developed to encourage pollination by beetle.</p>

答案 2 :(得分:-3)

试试这个,希望它对你有用; .align-center img { display:block; margin:0px auto; }