【问题标题】:Trying to put borders in consecutive <div> in php试图在 php 中连续 <div> 放置边框
【发布时间】:2023-03-09 18:01:02
【问题描述】:

我正在尝试使用“float: left”在我的代码中添加边框以尝试获得此解决方案:

但是当我在 CSS 中添加“边框”样式时,我得到了这个:

我的代码和解决方案:

php代码:

<?php

function pinta($n,$m){
    $cadena="";
    for($i=0;$i<$n;$i++){
        for($j=0;$j<$m;$j++){

            $x = 0+$i*10;
            $y = 0+$j*10;
            $cadena.="<div style='background-color:rgb(0,$x,$y); '>&nbsp;</div>";
        }
        $cadena.="<br/>";
    }
    return $cadena;
}

?>


<!DOCTYPE HTML>
<!-- start static html -->
<html>
    <head>
        <title>cursor</title>
        <meta charset="UTF-8">
        <link rel="stylesheet" type="text/css" href="estilo.css">
        <script src="script.js"></script> 
    </head>
    <body>
        <?php 
            echo pinta(9,9);
        ?>
        <script>
        </script>
    </body>
</html>

css代码:

div{
    width:40px;
    float: left;
}

【问题讨论】:

标签: php html css


【解决方案1】:

试试这个:

div{
    width: 40px;
    border: 1px solid black;
    display: inline-block;
}

Example

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2019-08-11
    • 1970-01-01
    相关资源
    最近更新 更多