位置:绝对不清除,仍然溢出

时间:2015-11-01 06:55:15

标签: html css css-float css-position

我在这里设置了一个jsfiddle来显示正在发生的事情:

https://jsfiddle.net/ok87vwnw/

我使用了传统的clear:both;方法,并添加了冗余命令和div,并使用了建议的overflow:hidden技巧。我想要的是让sivContent扩展到它内部的内容大小(主要是文本)。然后我也希望sivHold能够覆盖所有这些。

我希望任何修复都不需要在其css中设置任何元素的高度 - 这是其他人将要使用的内容,并且他们无法访问我的Dropbox,因此他们不会能够在每次添加更多内容时编辑css。这个容器需要灵活。

我在下面提供了我的代码。

HTML:

<link href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,700italic,400italic" rel="stylesheet" type="text/css">
<div id="sivHold">
<div id="sivGIFHold">
<div id="sivName">TESTING TITLE</div>
</div>

<div id="sivTabs"><div class="sivTab"><input type="radio" id="tab-1" name="tab-group-1" checked><label for="tab-1" id="titleTab1">Threads</label> 
<div class="sivContent">
ACTIVE
[??] Thread Name located in Location
10 Reason
10 Reason
20 Total - Claimed/Unclaimed

INACTIVE
[??] Thread Name located in Location
10 Reason
10 Reason
20 Total - Claimed/Unclaimed

COMPLETED
[??] Thread Name located in Location
10 Reason
10 Reason
20 Total - Claimed/Unclaimed
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</div>
<div class="sivTab">
<input type="radio" id="tab-2" name="tab-group-1"><label for="tab-2" id="titleTab2">Orders</label>   
<div class="sivContent">
ORDER FIVE
[X] Current Order!

ORDER FOUR
[o] [o] [o] [o] [o] Use magic in 5 threads

ORDER THREE
[o] Use magic during a hunt
[o] Train/Be-trained-by another character
[o] Purchase an additional spell

ORDER TWO
[o] Use magic against the Creature Account
[o] Use magic on a character not in your pack
[o] Use magic to help another character
[o] Use magic in 2 additional threads (not included in the above)

ORDER ONE
[o] Demonstrate one Customized Spell
[o] Use magic on 2 characters (not during training)
[o] Help train 2 wolves of a equal/lower order
[o] Use magic in 3 additional threads (not included in the above)
<div style="clear:both;"></div>
</div> 
<div style="clear:both;"></div>
</div>
<div class="sivTab">
<input type="radio" id="tab-3" name="tab-group-1"><label for="tab-3" id="titleTab3">Upgrades</label>
<div class="sivContent">
Total Biscuits Needed: XXXXB
MAGIC
Spell - XXXB

MUTATIONS
Mutation - XXXB

SKILL-TRAITS
Skill-Trait - XXXB

ITEMS
Item - XXXB

ARTIFACTS
Artifact - XXXB

ARMOR
Armor - XXXB

POTIONS
Potion - XXXB

TOKENS
Token - XXXB
<div style="clear:both;"></div>
</div> 
<div style="clear:both;"></div>
</div>
</div>
</div>
</div>
</center>

CSS:

#sivHold {
background: #272733 url('http://s2.postimg.org/m59xr8lg9/Sivaas_BG.png');
padding:20px;
width:550px;
border:10px solid #1e1e29;
}
#sivGIFHold {
background:url('http://s11.postimg.org/sq8bkw28x/Sivaas_Gif.gif');
height:550px;
width:550px;
text-align:center;
}

#sivPack {
background: rgba(30,30,41, 0.3);
padding:10px;
border-radius:37px;
height:54px;
width:54px;
margin-top:50px;
display:inline-block;
}

#sivName {
font-family:Ubuntu;
font-size:35px;
color:#dac4b3;
margin-top:20px;
letter-spacing:5px;
background: rgba(30,30,41, 0.8);
padding:10px;
border-radius:5px;
display:inline-block;
}

#sivTabs {
  position: relative;   
  clear: both;
  margin-top: -300px;
  padding:5px;
}
.sivTab {
  float: left;
  overflow:hidden;
}
.sivTab label {
  background: rgba(59,59,73,0.5);
  padding: 10px; 
  border:; 
  margin-left: -1px; 
  position: relative;
  left: 1px; 
  font-family:Ubuntu;
  font-size: 25px;
  letter-spacing: 2px;
  transition: 0.5s;
  border-radius: 5px;
}

.sivTab label:hover {
background: rgba(59,59,73,0.8);
transition: 0.5s;
}

#titleTab1 {
color: #d1d97e;
margin-left:80px;
}
#titleTab2 {
color: #c8ae9a;
}
#titleTab3 {
color: #272733;
}
.sivTab [type=radio] {
  display: none;   
}
.sivContent {
  position: absolute;
  left: 0px;
  top: 150px;
  background: #000;
  right: 0;
  bottom: 0;
  padding: 20px;
  border: 1px solid #272733; 
  color: #fff;
  overflow:hidden;
  height:100%;
  clear: both;
}

[type=radio]:checked ~ label {
  background: #3b3b49;
  border-bottom:#;
  z-index: 2;
}
[type=radio]:checked ~ label ~ .sivContent {
  z-index: 1;
}

1 个答案:

答案 0 :(得分:0)

为了让它以你想要的方式工作,我不得不重写整个事情,HTML和CSS。希望你能用到这个!

#sivHold {
  background: #272733 url('http://s2.postimg.org/m59xr8lg9/Sivaas_BG.png');
  padding: 20px;
  width: 550px;
  border: 10px solid #1e1e29;
}
#sivGIFHold {
  background: url('http://s11.postimg.org/sq8bkw28x/Sivaas_Gif.gif');
  /*background: url('http://s11.postimg.org/du9sdaqu9/Sivaas_Gif.gif');*/
  height: 550px;
  width: 550px;
  text-align: center;
}
#sivPack {
  background: rgba(30, 30, 41, 0.3);
  padding: 10px;
  border-radius: 37px;
  height: 54px;
  width: 54px;
  margin-top: 50px;
  display: inline-block;
}
#sivName {
  font-family: Ubuntu;
  font-size: 35px;
  color: #dac4b3;
  margin-top: 20px;
  letter-spacing: 5px;
  background: rgba(30, 30, 41, 0.8);
  padding: 10px;
  border-radius: 5px;
  display: inline-block;
}
#sivMenu {
  margin-top: -300px;
  padding-left: 80px;
}
#sivMenu label {
  background: rgba(59, 59, 73, 0.5);
  padding: 10px;
  float: left;
  left: 1px;
  font-family: Ubuntu;
  font-size: 25px;
  letter-spacing: 2px;
  transition: 0.5s;
  border-radius: 5px;
}
#sivMenu label:hover {
  background: rgba(59, 59, 73, 0.8);
  transition: 0.5s;
}
#titleTab1 {
  color: #d1d97e;
}
#titleTab2 {
  color: #c8ae9a;
}
#titleTab3 {
  color: #272733;
}
#sivTabs {
  position: relative;
  clear: both;
  padding: 5px;
  margin-top: 100px;
}
#sivHold [type='radio'] {
  display: none;
}
.sivTab {
  display: none;
}
.sivContent {
  background: #000;
  padding: 20px;
  padding-top: calc(20px - 1em);
  border: 1px solid #272733;
  color: #fff;
  white-space: pre-line;
  text-align: left;
}
#tab-1:checked ~ #sivTabs .sivTab:first-child,
#tab-2:checked ~ #sivTabs .sivTab:first-child + .sivTab,
#tab-3:checked ~ #sivTabs .sivTab:first-child + .sivTab + .sivTab {
  display: block;
}
#tab-1:checked ~ #sivMenu label[for='tab-1'],
#tab-2:checked ~ #sivMenu label[for='tab-2'],
#tab-3:checked ~ #sivMenu label[for='tab-3'] {
  background: #3b3b49;
}
<div id="sivHold">
  <div id="sivGIFHold">
    <div id="sivName">
      <b>SIVAAS &diam; GLAKEL</b><br /><span style="font-size:12px;display:inline-block;">SILVER GLADE CYPRESSMEN</span>
    </div>
  </div>

  <input type="radio" id="tab-1" name="tab-group-1" checked="checked"/>
  <input type="radio" id="tab-2" name="tab-group-1"/>
  <input type="radio" id="tab-3" name="tab-group-1"/>
  <div id="sivMenu">
    <label for="tab-1" id="titleTab1">Threads</label>
    <label for="tab-2" id="titleTab2">Orders</label>
    <label for="tab-3" id="titleTab3">Upgrades</label>
  </div>
  
  <div id="sivTabs">
    <div class="sivTab">
      <div class="sivContent">
        ACTIVE
        [??] Thread Name located in Location
        10 Reason
        10 Reason
        20 Total - Claimed/Unclaimed

        INACTIVE
        [??] Thread Name located in Location
        10 Reason
        10 Reason
        20 Total - Claimed/Unclaimed

        COMPLETED
        [??] Thread Name located in Location
        10 Reason
        10 Reason
        20 Total - Claimed/Unclaimed
      </div>
    </div>
    <div class="sivTab">
      <div class="sivContent">
        ORDER FIVE
        [X] Current Order!

        ORDER FOUR
        [o] [o] [o] [o] [o] Use magic in 5 threads

        ORDER THREE
        [o] Use magic during a hunt
        [o] Train/Be-trained-by another character
        [o] Purchase an additional spell

        ORDER TWO
        [o] Use magic against the Creature Account
        [o] Use magic on a character not in your pack
        [o] Use magic to help another character
        [o] Use magic in 2 additional threads (not included in the above)

        ORDER ONE
        [o] Demonstrate one Customized Spell
        [o] Use magic on 2 characters (not during training)
        [o] Help train 2 wolves of a equal/lower order
        [o] Use magic in 3 additional threads (not included in the above)
      </div>
    </div>
    <div class="sivTab">
      <div class="sivContent">
        Total Biscuits Needed: XXXXB
        MAGIC
        Spell - XXXB

        MUTATIONS
        Mutation - XXXB

        SKILL-TRAITS
        Skill-Trait - XXXB

        ITEMS
        Item - XXXB

        ARTIFACTS
        Artifact - XXXB

        ARMOR
        Armor - XXXB

        POTIONS
        Potion - XXXB

        TOKENS
        Token - XXXB
      </div>
    </div>
  </div>
</div>