2014-08-31 2 views
0

Я изо всех сил пытаюсь понять, как позиционировать # book3 внизу # content-body-container и обернуть текст вокруг # book3. Я не могу использовать верхний край на # book3, потому что тогда текст не обернется вокруг него. Мне нужен подход, который должен быть совместим с браузером, а также работать в старых браузерах. Я хотел бы чистый раствор HTML/CSS, если это возможноВыровнять div в нижней части содержащего div и обернуть текст вокруг нижнего div

скрипку доступны here

<html> 
<head> 
    <style> 
    #content { 
     width: 960px; 
     height: 600px; 
     margin: 0; 
    } 

    #content-body-container { 
     position: relative; 
     float: left; 
     top: 28px; 
     width: 495px; 
     border: 1px solid black; 
     height: 462px; 
    } 

    #book3 { 
     position: relative; 
     float: left; 
     /*margin-top:117px;*/ 
     /*top: 145px;*/ 
     bottom: 0; 
     height: 345px; 
     width: 88px; 
     background-color: #ffe3b1; 
    } 
    #book1 { 
     position: relative; 
     float: left; 
     top: 61px; 
     bottom: 0; 
     height: 429px; 
     width: 79px; 
     margin-right: 16px; 
     background-color: #ffd48b; 
    } 

    #book2 { 
     position: relative; 
     float: left; 
     top: 28px; 
     bottom: 0; 
     height: 462px; 
     width: 28px; 
     margin-right: 12px; 
     background-color: #ffc664; 
    } 

    #link-book1 { 
     position: absolute; 
     bottom: 54px; 
    } 

    #link-book3 { 
     position: absolute; 
     margin-left: 2px; 
     bottom: 16px; 
    } 


    </style> 
</head> 
<body> 
    <div id="content"> 
     <div id="content-body" class="content-wrapper"> 

      <div id="book1"> 
       <a href="#" id="link-book1" class="book-link">Book 1</a> 
      </div> 

      <div id="book2"></div> 

      <div id="content-body-container"> 
       <div id="book3"> 
        <a href="#" id="link-book3" class="book-link">Book 3</a> 
       </div> 
       <div id="content-body-text"> 
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. 

        Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. 

        Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. 

        Suspendisse in justo eu magna luctus suscipit. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. 

       </div> 

      </div> 
     </div> 
    </div> 
</body> 
</html> 

ответ

1

Если height контейнера и перемещаемого блока является постоянным, вы можете добавить padding-top в контейнер, а также добавить отрицательный margin-top к блоку, содержащий текст для достижения эффекта:

EXAMPLE HERE

#content-body-container { 
    /* other declarations... */ 
    height: 462px; 
    box-sizing: border-box; 

    padding-top: 117px; /* 462px - 345px */ 
} 

#content-body-text { margin-top: -117px; } 

box-sizing: border-box; используется, чтобы заставить UA рассчитать height коробки, включая прокладку и границы.

Это supported even in IE8. Однако вы можете уменьшить height, если вы добавите padding-top.

Смежные вопросы