我对css有点生疏,我坚持这个,我想要达到的目的是让两个div并排显示两个顶角的图像,这个我已经做了很多(我希望正确) ,我所困扰的是尝试将两个并排的div放在中心,我目前无法打破它而不会破坏它
任何帮助都会很棒,谢谢
<style>
#wrapper {
margin:0 auto;
height:auto;
overflow: hidden; /* add this to contain floated children */
}
#first {
width: 300px;
float:left; /* add this */
color:#FFF;
padding:0 5px 5px 5px;
background: url(view.image?id=598) 0 100% #fcb033 no-repeat;
}
#second {
width: 300px;
float: left;
padding:0 5px 5px 5px;
color:#FFF;
background: url(view.image?id=595) 100% 100% #c1d72e no-repeat;
}
#overlayleft{
position:absolute;
top:-40px;
left:-30px;
}
#overlayright{
position:absolute;
top:-40px;
left:570px;
}
</style>
<div id"wrapper">
<div id="first"><div id="overlayleft"><img alt="Dr Sayer" height="94" src="view.image?Id=592" width="93" /></div><h1 style="text-align:right">Dr John Sayer</h1><p>Cystic kidney diseases, such as polycystic kidney
disease (PKD), are responsible for ten per cent of
patients requiring dialysis and transplantation in
the UK. As with most cystic kidney diseases, PKD
is a genetic condition which causes fluid-filled
sacks to develop on the interior and exterior of
the kidneys. These sacks gradually replace normal
kidney tissue, enlarging the organs and reducing
their ability to function – eventually causing them
to fail altogether. A recently discovered gene,
involved in the onset of cystic kidney diseases,
has provided a basis for the work of Dr John Sayer.
Dr Sayer is studying this specific gene closely and
hopes not only to improve our understanding of
the molecules which cause cystic kidney diseases,
but also test potential new drug treatments aimed
at preventing the formation of cysts.</p></div>
<div id="second"><div id="overlayright"><img alt="Donate" height="94" src="view.image?Id=592" width="93" /></div><h1>Carol Norbury</h1>
<p>Carol Norbury’s family has a prolonged history of polycystic
kidney disease. Her husband, John, was diagnosed with the condition in 1996, before
going on to suffer complete renal
failure in late 2004. Luckily, Carol
was found to be a suitable organ
donor. However, since then, each
of Carol and John’s three children
has been diagnosed with
the condition.</p></div>
<div class"clear"></div>
</div>
答案 0 :(得分:0)
您必须在包装上为“margin:0 auto”指定宽度。工作。
您错过了包装ID
上的等号