html - position:absolute h1 element overflowing right -


i have container has of following css rules (taken chrome dev toolbar):

border-bottom-color: rgb(85, 85, 85); border-bottom-style: none; border-bottom-width: 0px; border-image-outset: 0px; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; border-left-color: rgb(85, 85, 85); border-left-style: none; border-left-width: 0px; border-right-color: rgb(85, 85, 85); border-right-style: none; border-right-width: 0px; border-top-color: rgb(85, 85, 85); border-top-style: none; border-top-width: 0px; box-shadow: none; box-sizing: border-box; color: rgb(85, 85, 85); display: block; font-family: 'open sans', helvetica, arial, sans-serif; font-size: 16px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: 100; height: 680px; line-height: 25.9200000762939px; margin-bottom: 0px; margin-left: 411.5px; margin-right: 411.5px; margin-top: 0px; max-width: 1080px; padding-bottom: 40px; padding-left: 60px; padding-right: 60px; padding-top: 40px; position: relative; text-shadow: none; vertical-align: baseline; width: 1080px; 

there child h1 element these css rules:

h1 {     font-size: 42px;     line-height: 42px;     position: absolute;     top: 50%;     top: calc(50% - 21px);     right: 0;     text-align: right;     margin: 0;     padding: 0; } 

however, text overspills right of container:

screenshot 1

screenshot 2

how can ensure h1 element snaps right hand side of parent element, without overspilling?

edit: other element, ipad image, has following css code:

.ipad {     width: 251px;     height: 600px;     background-image: url(../img/ipad.png);     background-repeat: no-repeat;     background-size: contain;     display: absolute;     left: 0; top: 0; } 

the html follows:

<div class="canvas">      <div class="wrapper normal referrals">          <div style="position: relative;">              <div class="referrals fade ipad" data-order="1"></div>              <h1>referrals</h1>          </div>      </div>  </div> 

how h1 element ignores parent element's padding, other element not?

the reason other element not overflowing padding because has display: absolute in stead of position: absolute;

create new div .container position:relative; inside div .wrapper.

html

<div class="wrapper normal referrals">     <div class="container">         <div class="referrals fade ipad" data-order="1"></div>         <h1>referrals</h1>     </div> </div> 

css

.container {     position:relative; } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -