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.
So I decided to try my hand at creating a html and css design which would look like this eventually.
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
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 ?
Try adding this to your CSS
working demo http://jsfiddle.net/aavk7g9m/2/
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:
CSS: