2016-08-03 3 views
0

HTML/CSS 순서도를 만들려고합니다. 나는 모든 것을 한 화면 크기의 화면에 맞춰보기를 원하지만 현재는 그렇지 않다. 상자 너비 안에 작은 너비와 텍스트가있는 개별 상자에는 신경 쓰지 않아도됩니다.HTML/CSS 화면이 화면보기에 맞지 않습니다.

나는 누군가가 CSS 코드를 볼 수 있기를 바랬다. 빠른 수정이 필요한 것 같다. .tree 리튬의 국지적 목록 요소에 대한 사용 플로트가 다음 행으로되어 있기 때문에 그것은을 제공 .SO .tree 전체 폭을 점유 할 때 http://thecodeplayer.com/walkthrough/css3-family-tree

<html> 
<head> 

<style> 



li { 
white-space: nowrap; // stop the wrapping in the first place 
} 

/*Now the CSS*/ 
* {margin: 0; padding: 0;} 

.greenBox { 
border: 2px solid #007f00 !important; 
background-color:#e5ffe5; 
} 

.redBox { 
border: 2px solid #FF0000 !important; 
background-color:#ffe5e5; 
} 


.tree ul { 
padding-top: 20px; position: relative; 

transition: all 0.5s; 
-webkit-transition: all 0.5s; 
-moz-transition: all 0.5s; 
} 

.tree li { 
float: left; text-align: center; 
list-style-type: none; 
position: relative; 
padding: 20px 5px 0 5px; 

transition: all 0.5s; 
-webkit-transition: all 0.5s; 
-moz-transition: all 0.5s; 
} 

/*We will use ::before and ::after to draw the connectors*/ 

.tree li::before, .tree li::after{ 
content: ''; 
position: absolute; top: 0; right: 50%; 
border-top: 1px solid #ccc; 
width: 50%; height: 20px; 
} 
.tree li::after{ 
right: auto; left: 50%; 
border-left: 1px solid #ccc; 
} 

/*We need to remove left-right connectors from elements without 
any siblings*/ 
.tree li:only-child::after, .tree li:only-child::before { 
display: none; 
} 

/*Remove space from the top of single children*/ 
.tree li:only-child{ padding-top: 0;} 

/*Remove left connector from first child and 
right connector from last child*/ 
.tree li:first-child::before, .tree li:last-child::after{ 
border: 0 none; 
} 
/*Adding back the vertical connector to the last nodes*/ 
.tree li:last-child::before{ 
border-right: 1px solid #ccc; 
border-radius: 0 5px 0 0; 
-webkit-border-radius: 0 5px 0 0; 
-moz-border-radius: 0 5px 0 0; 
} 
.tree li:first-child::after{ 
border-radius: 5px 0 0 0; 
-webkit-border-radius: 5px 0 0 0; 
-moz-border-radius: 5px 0 0 0; 
} 

/*Time to add downward connectors from parents*/ 
.tree ul ul::before{ 
content: ''; 
position: absolute; top: 0; left: 50%; 
border-left: 1px solid #ccc; 
width: 0; height: 20px; 
} 

.tree li a{ 
border: 1px solid #ccc; 
padding: 5px 10px; 
text-decoration: none; 
color: #666; 
font-family: arial, verdana, tahoma; 
font-size: 11px; 
display: inline-block; 

border-radius: 5px; 
-webkit-border-radius: 5px; 
-moz-border-radius: 5px; 

transition: all 0.5s; 
-webkit-transition: all 0.5s; 
-moz-transition: all 0.5s; 
} 

/*Time for some hover effects*/ 
/*We will apply the hover effect the the lineage of the element also*/ 
.tree li a:hover, .tree li a:hover+ul li a { 
background: #c8e4f8; color: #000; border: 1px solid #94a0b4; 
} 
/*Connector styles on hover*/ 
.tree li a:hover+ul li::after, 
.tree li a:hover+ul li::before, 
.tree li a:hover+ul::before, 
.tree li a:hover+ul ul::before{ 
border-color: #94a0b4; 
} 

/*Thats all. I hope you enjoyed it. 
Thanks :)*/ 
</style> 


</head> 

<body> 
<!-- 
We will create a family tree using just CSS(3) 
The markup will be simple nested lists 
--> 
<div class="tree" style="white-space: nowrap;"> 
<ul> 
    <li> 
    <a href="#">E. coli</a> 
     <ul> 
      <li> 
       <a href="#">Live</a> 
       <ul> 
        <li> 
         <a href="#">Keep</a> 
         <ul> 
          <li> 
          <a href="#">Excreted</a> 
           <ul> 
            <li> 
             <a href="#" class="greenBox">Effective waste treatment</a> 
            </li> 
            <li> 
             <a href="#">Poor waste treatment</a> 
             <ul> 
              <li> 
              <a href="#" class="redBox">Unknown consequence to environment</a> 
              </li> 
              <li> 
               <a href="#">Contaminate other people</a> 
              </li> 
             </ul> 
            </li> 
           </ul> 
          </li> 
          <li> 
           <a href="#">Stay in gut</a> 
           <ul> 
            <li> 
             <a href="#" class="redBox">Work too well -> copper deficiency risk</a> 
            </li> 
            <li> 
             <a href="#">Imbalance (overgrowth)</a> 
             <ul> 
            <li> 
             <a href="#" class="redBox">Progressive recovery of the microbiome</a> 
            </li> 
              <li> 
             <a href="#" class="redBox">Unpredictable damage</a> 
            </li> 
              <li> 
             <a href="#" class="redBox">Digestive disorder</a> 
            </li> 
           </ul> 
            </li> 
            <li> 
             <a href="#">Equilibrium with other flora</a> 
             <ul> 
            <li> 
             <a href="#" class="redBox">Share genetic information - unknown danger</a> 
             <ul> 

           </ul> 
            </li> 
            <li> 
             <a href="#" class="redBox">Mutation - unknown danger</a> 
             <ul> 

           </ul> 
            </li> 
              <li> 
             <a href="#" class="redBox">Integration into microbiome - danger</a> 
            </li> 
           </ul> 
            </li> 
           </ul> 
          </li> 
         </ul> 
        </li> 
        <li> 
         <a href="#" class="greenBox">Lose plasmid</a> 
        </li> 
       </ul> 
      </li> 

      <li> 
       <a href="#">Dead</a> 
       <ul> 
        <li> 
         <a href="#">After low absorption</a> 
         <ul> 
          <li> 
           <a href="#" class="greenBox">No consequence</a> 
          </li> 
          <li> 
           <a href="#" class="greenBox">Modification of the gut microbiome</a> 
          </li> 
         </ul> 
        </li> 
        <li> 
         <a href="#">After high absorption</a> 
         <ul> 
          <li> 
           <a href="#">Modify Cu level significantly</a> 
           <ul> 
          <li> 
           <a href="#" class="greenBox">No consequence</a> 
          </li> 
          <li> 
           <a href="#">Modification of the gut microbiome</a> 

           <ul> 
          <li> 
           <a href="#" class="greenBox">Proliferation of neutral strains</a> 
          </li> 
          <li> 
           <a href="#" class="greenBox">Proliferation of pathogenic strains</a> 
          </li> 
         </ul> 
          </li> 
         </ul> 
          </li> 
          <li> 
           <a href="#" class="greenBox">Very low Cu absorption by gut</a> 
          </li> 
         </ul> 
        </li> 
       </ul> 
      </li> 
     </ul> 
    </li> 
</ul> 
</div> 



</body> 
</html> 

답변

0

:

나는 거기에서 원래의 코드를 가지고 당신에게 폭 부모 컨테이너

확인이 바이올린 : 내가 업데이트 한 UR 코드

+0

jsfiddle.net/ygpyn20f – subbu

+0

친애하는 subbu1191, 대단히 감사합니다. 문제가 해결되었습니다. 또 다른 문제는 전체를보기 위해 너비 방향으로 스크롤해야한다는 것입니다. 상자 폭이 자동으로 좁아지기 때문에 전체 줄이 여러 줄로 줄 바꿈되는 한 페이지에 맞춰 지는지 궁금합니다. 많은, 많은 감사합니다! –

0

목 anks 아주 많이, 이것은 문제가 해결되고있다. 또 다른 문제는 전체를보기 위해 너비 방향으로 스크롤해야한다는 것입니다. 상자 폭이 자동으로 좁아지기 때문에 전체 줄이 여러 줄로 줄 바꿈되는 한 페이지에 맞춰 지는지 궁금합니다.

많은 분들께 감사드립니다. Gaurav

관련 문제