如何阻止栏重叠

I have this barcode generation code.

The actual generation part is:

$valoare = substr($code_string, ($position-1), 1);
            if($valoare==1)
                $cur_size = 0.5;
            elseif($valoare==2)
                $cur_size = 1;
            elseif($valoare==3)
                $cur_size = 1.5;
            elseif($valoare==3)
                $cur_size = 2;
            if ( strtolower($orientation) == "horizontal" )
                draw_bar($cur_size, ($position % 2 == 0 ? $white : $black) );

Function draw_bar:

function draw_bar($cur_size, $color){

    ?>
    <div style="width:<?php echo $cur_size?>; height:40px; background-color:<?php echo $color; ?>;float:left; position:relative"></div>
    <?php
}

For big values of $cur_size the generated barcode is correct. For smaller sizes, the bars overlap, so instead of two small bars separated by a white space, I get one big bar. The more I zoom in, the barcode resizes to a correct form.

Here are two images, the first one is incorrect, the second in correct, after zooming 200%.

enter image description here

enter image description here

How can I stop bars from overlapping at small sizes?

Thank you!