English 中文(简体)
CSS 以层动力 d为中心
原标题:CSS center layered dynamic divs
  • 时间:2012-05-04 19:09:33
  •  标签:
  • css

这一点有些难于说明...... 从根本上讲,我想的是这一局面,但内容不断变化。

“entergraph

so I set up my html like this, basically all the elements are piled into the wrapper, the pictures and titles will be dynamically rotating and will be different widths and heights:

<div id="wrapper">
<div id="title"><h2></div>
<div id="image"><img></div>
<div id="leftbutton" class="but"><img></div>
<div id="rightbutton" class="but"><img></div>
</div>

我曾尝试过Hasn t。 我应如何做到这一点?

我最接近的是这一点,但标题领域可能改变高点,使这种方法无法奏效,因为我不得不将图像及其相对位置的变化与标题要素的扩大和缩小:

#wrapper{
position:relative;
text-align: center;
}
.but{
z-index:20;
position:absolute;
}
#leftbutton{
left:0px;
}
#rightbutton{
right:0px;
}
#title{
z-index: 3;
display: inline-block;
width:auto;
min-width: 80px;
max-width: 340px;
}
#image{
z-index: 1;
position: relative;
top:-21px;
}
问题回答

If you mean the Title in the center use this way:

#title {
    margin: 0 auto;
    width: /* your width */
}

职位应该相对平衡。

<http://jsfiddle.net/Zpa9n/1/"rel=“nofollow”>JsFiddle UP

I just reorganized the body structure, adding one more div and floating everything. Then inside the central section I added title and image that you can style to be centered to the relative div.

如果你提供了一些实例,我们将能够更好地协助你。 同时,以下法典应照顾到你回顾的:

传真

<div id="wrapper">
    <div id="title"><h2>Article Headline</h2></div>
    <div id="image"><img></div>
    <div id="leftbutton"><img></div>
    <div id="rightbutton"><img></div>
</div>​

CSS

​#wrapper {
    background:#6cb6d9;
    display:inline-block;
    position:relative;} 

#title {
    position:absolute;
    top:0;
    width:100%;
    text-align:center;}

#title h2 {
    background:green;
    color:white;
    padding:10px 15px 10px 15px;
    display:inline-block;
    max-width:200px}

#image {}

#image img {
    min-width:200px;
    height:300px;
    width:500px; }

#leftbutton {
    position:absolute;
    left:0;
    top:0;
    height:100%;
    width:75px;
    background:black;}

#rightbutton {
    position:absolute;
    right:0;
    top:0;
    height:100%;
    width:75px;
    background:black;}

虽然不严格控制免疫机能,但只是排除了中央安全局的这些线线,使之自动适应成像的缺省规模。

rel=“nofollow>http://jsfiddle.net/b7c7c/

这些解决办法没有一个是正确的,最终如何使其发挥作用,是用这一trick计:。 如何将绝对位置放在干iv中?

然后,你就把所有要素完全放在总结中,而后一要素则相对而言。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签