CSS İle Div Ortalamak
-
Sayfamı 1024*748 e göre ayarlayıp Dreamweaver ile tasarladım, fakat sayfa başka çözünürlük ayarlarında ortalanmıyor, sola yaslı çıkıyor. Sorunu nasıl çözebilirim? Kod aşağıda...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#bg {
position: absolute;
width: auto;
height: auto;
z-index: 1;
left: 0px;
top: -1px;
background-image: url(../bg.png);
}
#bg #apDiv1 {
position: absolute;
width: 1024px;
height: 180px;
z-index: 1;
left: 0px;
top: -1px;
}
#bg #apDiv2 {
position: absolute;
width: 1024px;
height: 238px;
z-index: 2;
left: -14px;
top: 179px;
}
#bg #apDiv3 {
position: absolute;
width: 270px;
height: 33px;
z-index: 1;
left: 772px;
top: -158px;
}
#bg #word {
position: absolute;
width: 153px;
height: 17px;
z-index: 1;
left: 15px;
top: 3px;
border: 0px solid;
}
</style>
</head>
<body>
<div id="bg">
<div id="apDiv1"><img src="../images/Untitled-2_02.png" width="138" height="180" alt="anasayfa" /><img src="../images/Untitled-2_03.png" width="200" height="180" alt="satiliklar" /><img src="../images/Untitled-2_04.png" width="179" height="180" alt="kiraliklar" /><img src="../images/Untitled-2_05.png" width="147" height="180" alt="arama" /><img src="../images/Untitled-2_06.png" width="211" height="180" alt="hakkimizda" /><img src="../images/Untitled-2_07.png" width="149" height="180" alt="iletisim" />
</div>
<div id="apDiv2"><img src="../emlak banner (1).jpg" width="1037" height="151" alt="banner" />
<div id="apDiv3"><img src="../images/search-fields_03.png" width="190" height="40" alt="search_text" />
<div id="word">
<form id="form1" name="form1" method="post" action="">
<label for="word"></label>
<input type="text" name="word" id="word" />
</form>
</div>
<img src="../images/search-fields_04.png" width="67" height="40" alt="search_button" />
</div>
<img src="../ALT.jpg" width="1037" height="86" alt="alt" />
</div>
</div>
</body>
</html>
-
width: height: auto vermişsin bunlar ne?
genel container divi aç içinde olsun içerikler o container'ı da
div#container {
width:980px;
height:auto;
margin-left:auto;
margin-right:auto;}
dediğinde ortalar
-
body e 1024 ver sonra margin:0px auto;
-
hocam kodu düzelttim ama işe yaramadı aynen kopyalıyorum sorun nerde?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#container {
width:980px;
height:auto;
margin-left:auto;
margin-right:auto;
}
#bg {
position: absolute;
width: 1024px;
height: 748px;
z-index: 1;
left: 0px;
top: -1px;
background-image: url(../bg.png);
}
#apDiv1 {
position: absolute;
width: 1024px;
height: 180px;
z-index: 1;
left: 0px;
top: -1px;
}
#apDiv2 {
position: absolute;
width: 1024px;
height: 238px;
z-index: 2;
left: -14px;
top: 179px;
}
#apDiv3 {
position: absolute;
width: 270px;
height: 33px;
z-index: 1;
left: 772px;
top: -158px;
}
#word {
position: absolute;
width: 153px;
height: 17px;
z-index: 1;
left: 15px;
top: 3px;
border: 0px solid;
}
</style>
</head>
<body>
<div id="container">
<div id="bg">
<div id="apDiv1"><img src="../images/Untitled-2_02.png" width="138" height="180" alt="anasayfa" /><img src="../images/Untitled-2_03.png" width="200" height="180" alt="satiliklar" /><img src="../images/Untitled-2_04.png" width="179" height="180" alt="kiraliklar" /><img src="../images/Untitled-2_05.png" width="147" height="180" alt="arama" /><img src="../images/Untitled-2_06.png" width="211" height="180" alt="hakkimizda" /><img src="../images/Untitled-2_07.png" width="149" height="180" alt="iletisim" />
</div>
<div id="apDiv2"><img src="../emlak banner (1).jpg" width="1037" height="151" alt="banner" />
<div id="apDiv3"><img src="../images/search-fields_03.png" width="190" height="40" alt="search_text" />
<div id="word">
<form id="form1" name="form1" method="post" action="">
<label for="word"></label>
<input type="text" name="word" id="word" />
</form>
</div>
<img src="../images/search-fields_04.png" width="67" height="40" alt="search_button" />
</div>
<img src="../ALT.jpg" width="1037" height="86" alt="alt" />
</div>
</div></div>
</body>
</html>
-
böyle yapacaksan absolute pozisyonda
#bg{width:980;left :50%;margin-left:-490px;} yap
-
SinusX bunu yazdı
böyle yapacaksan absolute pozisyonda
#bg{width:980;left :50%;margin-left:-490px;} yap
işte bu işe yaradı sağol hocam
-
manyaki bunu yazdıSinusX bunu yazdı
böyle yapacaksan absolute pozisyonda
#bg{width:980;left :50%;margin-left:-490px;} yap
işte bu işe yaradı sağol hocam
üsttekinde yaramaz position'ın absolute olduğu için ya bg içindeki absolute u sil yada container a position:relative ver o zaman yine olur
-
body{width:1024px;
right:0px auto;
left:0px auto ;}
veya
body{width:1024px;
margin-left:auto;
margin-right:auto ;}
-
position:absolute
niteliğine sahip olan bir elementi css ile ortalayamazsın.
-
bu arada yer igelmişken sorayım bazen çok nadir de olsa <center> kullanıyorum eskide mi kaldı kullanmamalıyım kullanırsam sıkıntı olur mu v.sv.s ... .
-
asiminnesli bunu yazdı
bu arada yer igelmişken sorayım bazen çok nadir de olsa
kullanıyorum eskide mi kaldı kullanmamalıyım kullanırsam sıkıntı olur mu v.sv.s ... . html5 ile center kullanımı kalktı. center yerine css kullan. (text-align:center)
http://www.w3schools.com/tags/tag_center.asp
The <center> tag is not supported in HTML5. Use CSS instead.
