Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

span width and float on mpdf doesn't work

Tags:

html

mpdf

i am on developing report html using mpdf library. my code is:

..
<td style="width:400px">
<span style="float:left; width:60px;">Rp</span>
<span style="float:right; width:340px;">100</span>
</td>
..

i want it to be appear 'Rp' in left side and '100' in the right side, in the browser it shows perfect result as i want, but when generated into pdf, both of them is on the left side. and the width of the span doesnt correct. why this doesnt work?

someone help me please, thanks.

like image 977
Eko Dedy Avatar asked Oct 26 '25 10:10

Eko Dedy


2 Answers

Try to use "percent" instead of "px":

HTML:

<table>
    <tr>
        <td>
            <span>Rp</span>
            <span>100</span>
        </td>
        <td>
            second TD
        </td>
    </tr>
</table>

CSS:

table{
    width: 100%;
    border: 1px solid red;
}

td {
    width: 400px;
}

td span{
    float: left;
    border: 1px solid green;
    width: 20%;
    margin-right: 10px;
}

td span:nth-child(2){
    border: 1px solid blue;
    width: 60%;
}

Demo : http://jsfiddle.net/R5KW6/1/

like image 129
Arbaoui Mehdi Avatar answered Oct 29 '25 00:10

Arbaoui Mehdi


If you want to make space between some data and <span> with mpdf,alternatively you can also use entities, for example:

<span>&nbsp;YOUR TEXT HERE</span>

&nbsp - adds real non-breaking space
like image 25
just-Luka Avatar answered Oct 28 '25 23:10

just-Luka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!