Page 97 - CSS
P. 97

<p>Lorem ipsum</p>


        CSS


         p {
             text-align: center;
         }


        This does not work for centering entire block elements. text-align controls only alignment of inline
        content like text in its parent block element.

        See more about text-align in Typography section.


        Centering in relation to another item


        We will see how to center content based on the height of a near element.

        Compatibility: IE8+, all other modern browsers.


        HTML


         <div class="content">
           <div class="position-container">
             <div class="thumb">
               <img src="http://lorempixel.com/400/200/">
             </div>
             <div class="details">
               <p class="banner-title">text 1</p>
               <p class="banner-text">content content content content content content content content
         content content content content content content</p>
               <button class="btn">button</button>
             </div>
           </div>
         </div>


        CSS


         .content * {
           box-sizing: border-box;
         }
         .content .position-container {
           display: table;
         }
         .content .details {
           display: table-cell;
           vertical-align: middle;
           width: 33.333333%;
           padding: 30px;
           font-size: 17px;
           text-align: center;
         }
         .content .thumb {
           width: 100%;
         }
         .content .thumb img {



        https://riptutorial.com/                                                                               75
   92   93   94   95   96   97   98   99   100   101   102