skip to Main Content

I’m not a web developer but more of a photoshop designer, I set out to make a nice list style to add it in personal wordpress blog. I made the design inspired a lot from material design which came out really well like below picture.

enter image description here

So I decided to try my hand at creating a html and css design which would look like this eventually.

enter image description here

I tried adding some margin and padding to the text but it does not seem to move the content text towards the right. What should I do to fix this?

html code –

  <div>
  <ul>
    <li class="paper">
      <div class="papercontent">
      <img class="pimg" src="http://127.0.0.1:8080/wordpress/wp-content/uploads/2014/12/oneplus-one-top10.png" alt="oneplus-one-top10" width="452" height="300"  />
      <p class="pheader"><span class="pnumber">#1</span> OnePlus One</p>
      <p class="ptext"> Apple unveiled its new version of Mac OS X – Yosemite at this year’s WWDC 2014. And from using the beta, we think it’s beautiful. The new interface in Yosemite is simply superb. Even all the app icons get a new design. The new typography is arguably cleaner.</p>
      </div>
 </li>

My custom css other than the wordpress post css –

.paper {
  background-color: rgb(255, 255, 255);
  box-shadow: 1.5px 2.598px 8.6px 1.4px rgba(0, 0, 0, 0.09);
  font-size: 1.8em;
  padding: 30px;
  font-weight: 300;
  font-family: 'Helvetica Neue',sans-serif;
  }

.pnumber
{
  color:white;
}
.pheader
{
  font-size:35px;
}
.papercontent
{
  background-color: rgb(253, 19, 126);
}
.ptext
{
  margin-right: .1em;
  margin-left: .1em;
  font-size: 0.8em;
  padding: 30px;
  font-weight: 300;
  font-family: 'Helvetica Neue',sans-serif;
}   
 li {
  padding: 10px;
  overflow: auto;
}

 li:hover {
  background: #eee;
  cursor: pointer;
}
ul {
  list-style-type: none;
}
.pimg {
max-width: 100%;
  float: left;
height: auto;
}

If my methods are wrong, please direct me to the right way. Thank you

4

Answers


  1. jsfiddle example : jsfiddle.net/aavk7g9m/ (SO wouldn’t let me put the link without code and I don’t have any to show …)

    I think it’s working here ? I guess it’s the (wordpress) context then ?

    Login or Signup to reply.
  2. Try adding this to your CSS

    .ptext{
    padding-left:10px;
    }
    
    Login or Signup to reply.
  3. .pimg {
    max-width: 100%;
    float: left;
    height: auto;
    margin-right: 20px; /* add */
    }
    

    working demo http://jsfiddle.net/aavk7g9m/2/

    Login or Signup to reply.
  4. Check out my PEN
    I personally like to separate areas within elements for more granular control. In this case I have wrapped your photo and text in 2 separate divs so they can float next to each other.

    I have added box-sizing: border-box to all elements so that you can pad the text (as padding is added inside the boundaries of the elements’ border) in without affecting the width / layout of the list item – you should be using this if you like to have widths such as 60% + 40% = 100%. Without this the padding would be added to the outside thus breaking your layout as your divs would not equal 100% anymore.

    HTML:

     <div id="main">
         <ul>
             <li class="paper">
                 <div class="papercontent">
                     <div class="inner first">
                         <img class="pimg" src="http://placekitten.com/g/350/350" alt="oneplus-one-top10" />
                     </div>
                     <div class="inner second">
                         <p class="pheader"><span class="pnumber">#1</span> OnePlus One</p>
                         <p class="ptext"> Apple unveiled its new version of Mac OS X – Yosemite at this year’s WWDC 2014. And from using the beta, we think it’s beautiful. The new interface in Yosemite is simply superb. Even all the app icons get a new design. The new typography is arguably cleaner.</p>
                     </div>
    
                 </div>
             </li>
         </ul>
    </div>
    

    CSS:

    *, *:before, *:after {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }
    #main {
        display: block;
        margin: auto;
        max-width: 830px;
    }
    ul {
        margin: 0;
        padding: 0;
    }
    .paper {
      background-color: rgb(255, 255, 255);
      box-shadow: 1.5px 2.598px 8.6px 1.4px rgba(0, 0, 0, 0.09);
      font-size: 1.8em;
      padding: 30px;
      font-weight: 300;
      font-family: 'Helvetica Neue',sans-serif;
      }
    
    .pnumber
    {
      color:white;
    }
    .pheader
    {
      font-size:35px;
        margin: 0;
    }
    .papercontent
    {
      background-color: rgb(253, 19, 126);
        float: left;
    }
    .ptext
    {
      font-size: 0.8em;
      font-weight: 300;
      font-family: 'Helvetica Neue',sans-serif;
    }   
     li {
      padding: 10px;
      overflow: auto;
    }
    
     li:hover {
      background: #eee;
      cursor: pointer;
    }
    ul {
      list-style-type: none;
    }
    .pimg {
        max-width: 100%;
        float: left;
        height: auto;
    }
    .inner {
        float: left;
    }
    .inner.first {
        width: 40%;
    }
    .inner.second {
        width: 60%;
        padding: 16px;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search