1

私はこれが数時間新しいのに苦労していて、それを正しく理解することができません。私のCSSスキルは純粋なので、理解してください。

ですから、私が達成したいのは、Webサイトに画像があり、ブラウザウィンドウのサイズを変更するときに、画像サイズをブラウザサイズに調整する必要があるため、画像全体が表示されるようにすることです。また、画像はページの中央に配置する必要があります。助けてくれてありがとう。

index.php:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
<title>James Laycock</title>
</head>
<body>
<div id="main">
<div id="content">
<div id="image_container">
<a href="index.php?page=1"><img src="images/01.jpg" class="image" /></a></div>
</div></div></body></html>

style.css:

body{
margin: 0; 
padding: 0; 
padding-top: 10px;
text-align: center;}

#main {
height: 90%;
width: 1000px;
position: absolute;
border: 0px;
padding: 0;
margin: 0 auto;}

#content{
height: 90%;
width: auto;
margin-top: 10px;
margin-right:10px;}

#image_container{
height: 100%;
max-height:100%;
width: auto;}

.image{
height: 100%; 
width: auto;}
4

1 に答える 1

0

画像コンテナを入れてみてください

text-align:center

そして、実際の画像に高さ/幅をパーセンテージで入力します。

編集:画像コンテナを中央に配置するか、画像の幅を全画面に設定することも忘れないでください。

于 2012-07-03T15:21:20.897 に答える