Forum


Replies: 2   Views: 1880
Clear:both; css property
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by rapidtech  · 06-05-2020 - 06:48

Hi. I am using HTML to DOCX conversion. How to do something similar to "clear: both;" property in CSS? I need to have an export exactly the case as in HTML - http://joxi.ru/p279K0MtKgaBLr

Posted by admin  · 06-05-2020 - 08:57

Hello,

There's no equivalence in MS Word documents to clear: both. If you create a DOCX and then add an image, you can check you need to add line breaks to get that output (https://answers.microsoft.com/en-us/msoffice/forum/all/how-to-make-a-paragraph-stand-clear-of-floating/11a525d5-0d0c-402f-a8bb-0ef21accb619) or use absolute values to position the images.

Although you can do this task using phpdocx_image from HTML Extended, you'd need to use absolute values and it's a complex task. The easiest solution is using tables to get that output (hiding the borders if needed):

$html = '
    <style>
        td {
            vertical-align: top;
        }
    </style>
    <table>
        <tr>
            <td width="200px;">
                <img src="image.png">
            </td>
            <td width="400px;">
                Lorem ipsum
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td width="300px;">
                <img src="imageb.png">
            </td>
            <td width="300px;">
                Lorem ipsum
            </td>
        </tr>
    </table>
';

$docx->embedHTML($html);

 

Regards.

Posted by rapidtech  · 07-05-2020 - 06:06

Thanks. I've used 

<phpdocx_break />