Make 75% width for text and 100% for images in WordPress post?

I tried to make 75% width of paragraph in post, and also 100% responsive width of images. However, <img> is always in <p> as default.

<p>Some texts</p>
<p>Some texts</p>
<p><a><img src="..."></a></p>
<p>Some texts</p>
<p>Some texts</p>

Currently, I can only make .entry-content p {max-width: 75%;} and make a <div> outside the <img>. So that the system won’t create a <p> to hold <img>. But it’s not the best practice.

Read More

Any idea to this problem?

This is my ideal layout
This is the layout I expected.

Related posts

1 comment

  1. You can absolutely do this with pure CSS – no need of JS for that – it’s just maths. Considering your paragraphs are 75% of the container width, your image need to be 100% of paragraph width + the 25% missing of the container width. So with this formula you get the right percentage your image should have as width:

    width = ((25/75) + 1) * 100 = 133.3333
    

    Here is a jsfiddle illustrating this.

Comments are closed.