html - 如何让出现在表格边框和表格背景之间并让页面背景透出的烦人的1px边框消失?

标签 html css

一个 1px 的“边框”出现在边框内,该边框基本上是显示的页面背景,即使表格有设置的背景颜色。它基本上出现在边界旁边。

我尝试增加边框的宽度,希望它能覆盖它。

这是我这边的样子:[我这边的样子][1]

这是我的 css 文件,后面是我想在其中使用它的函数:

    width: 1000px;
    margin-left: auto;
    margin-right: auto;
}       
#title{
    height: 250px;
    width: 996px;
    border: 2px solid #0000ff;
    margin-left: auto;
    margin-right: auto;
    background-color: #55ff55;
    text-align: center;
}
#lefty{
    height: 600px;
    width: 246px;
    border: 2px solid #ff0000;
    margin-right: auto;
    background-color: #ff5555;
    padding: 10px;
}
#righty{
    height: 600px;
    width: 706px;
    border: 2px solid #00ff00;
    margin-left: auto;
    margin-top: -624px;
    background-color: #5555ff;
    padding: 10px;
}
.menu{
    display: block;
    height : 20px;
    width: 236px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: black;
    background-color: #bb0000;
    text-decoration: none;
}
.menu:hover{
    color: white;
    background-color: red;
}

table, td, th{
    border: 3px solid black;
}
table{
    border-collapse: collapse;
}
}

function MenutIr($x)
    {
        echo '<table align="center">';
        foreach($x as $index => $ertek)  
        {       
        echo '<tr><td>'; 
        echo '<a href=?menu='.$index.' class ="menu">'.$ertek.'</a>';
        echo '</td></tr>';
        }
        echo '</table>';
    }

EDIT: I couldn't make the snippet work but here is a working version of it:
<?php
session_start();
?>
<!DOCTYPE>
<html>
<html lang = "hu">
    <head>
        <title> </title>
        <meta charset = "UTF-8">
        <style>body{
    width: 1000px;
    margin-left: auto;
    margin-right: auto;
}       
#title{
    height: 250px;
    width: 996px;
    border: 2px solid #0000ff;
    margin-left: auto;
    margin-right: auto;
    background-color: #55ff55;
    text-align: center;
}
#lefty{
    height: 600px;
    width: 246px;
    border: 2px solid #ff0000;
    margin-right: auto;
    background-color: #ff5555;
    padding: 10px;
}
#righty{
    height: 600px;
    width: 706px;
    border: 2px solid #00ff00;
    margin-left: auto;
    margin-top: -624px;
    background-color: #5555ff;
    padding: 10px;
}
.menu{
    display: block;
    height : 20px;
    width: 236px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: black;
    background-color: #bb0000;
    text-decoration: none;
}
.menu:hover{
    color: white;
    background-color: red;
}

table, td, th{
    border: 3px solid black;
}
table{
    border-collapse: collapse;
}
}</style>
    </head>
    <body>
        <?php
        $menu[1] = "Beolvas";
        $menu[2] = "Tényező";
        $menu[3] = "Oszt";
        ?>
<?php
    function Debug($x)
    {
        echo '<pre>';
        print_r($x);
        echo '</pre>';      
    }
    function MenutIr($x)
    {
        echo '<table align="center">';

        /*
        vegigmegy a tombon a 
        beirt indexek sorrendje szerint
        index - index
        ertek - a tombben hasznalt ertek        
        */
        foreach($x as $index => $ertek)  
        {       
        /*
        table row, table data - minden elemet kulon sorban jelenit meg
        */
        echo '<tr><td>'; 
        echo '<a href=?menu='.$index.' class ="menu">'.$ertek.'</a>';
        echo '</td></tr>';
        }
        echo '</table>';
    }

    function Olvas(&$a)
    {
        if(!isset($_POST["a"]) || $_POST["a"]==""|| !is_numeric($_POST["a"]))
        {
            /*Urlap*/
            echo '<form name="Olvas" action="" method="post">';
            echo 'a = ';        
            echo '<input name="a" type="number" min ="1" size="3"<br><br>';
            echo '<input name="gomb" type="submit" value="Mehet">';
            echo '</form>';
            return 0;
        }
        else
        {

            $a = $_POST["a"];
            $_SESSION["a"] = $a;
            return 1;
        }
    }
    function Oszt($a)
    {
        $d=1;
        for($d=1; $d <= $a; $d++)
        {
            if($a%$d==0)
            {
                echo "$d ";
            }
        }
    }

    function Tenyezo($a)
    {
        $d=2;
        echo '<table>';
        while($a>1)
        {
            if($a%$d==0)
            {   
                echo '<tr><td style= "text-align:right; border-left-style:hidden; border-top-style:hidden; border-bottom-style:hidden;">'.$a.'</td><td style= "text-align:left; border-right-style:hidden; border-top-style:hidden; border-bottom-style:hidden;">'.$d.'</td></tr>';        
                $a = $a/$d;
            }
            else
            {
                $d++;
            }
        }
        echo '<tr><td style= "text-align:right; border-left-style:hidden; border-top-style:hidden; border-bottom-style:hidden;">1</td><td style= "text-align:left; border-right-style:hidden; border-top-style:hidden; border-bottom-style:hidden;"></td></tr>';        
        echo '</table>';
    }
?>
        <div id = "title"> Php kezdetek </div>
        <div id = "lefty"> 
            <?php
                MenutIr($menu);
            ?>  
        </div>
        <div id = "righty">
            <?php

            /*ha nem volt kattintas a menure*/
            $a = 0;
            $b = 0;
            if(!isset($_GET["menu"]))
            {           
                Debug($menu);
            }
            else
            {
                switch($_GET["menu"])
                {
                    case 1: //kattintas az elso mezon
                        echo $menu[1].'<br>';
                        if(Olvas($a))
                        {
                            echo "a=$a<br>";
                        }
                        break;
                    case 2: //kattintas a masodik mezon
                        echo $menu[2].'<br>';
                        if(!isset($_SESSION["a"]))
                        {
                            echo "Nincs mit osszeadni<br>";                     
                        }
                        else
                        {
                            $a=$_SESSION["a"];                      
                            Tenyezo($a);
                        }
                        break;
                    case 3: //kattintas a harmadik mezon
                        echo $menu[3].'<br>';
                        if(!isset($_SESSION["a"]))
                        {
                            echo "Nincs mit osszeadni<br>";                     
                        }
                        else
                        {
                            $a=$_SESSION["a"];                      
                            Oszt($a);
                        }
                        break;  
                    case 4: //kattintas a harmadik mezon
                        echo $menu[4].'<br>';
                        break;
                }
            }
            ?>              
        </div>
    </body>
</html>


  [1]: /image/3Ki0v.png

最佳答案

您需要添加“cellpadding='0'”以及“border-collapse: collapse;”在你的表格标签中是这样的:

echo "<table align='center' cellpadding='0'>";

关于html - 如何让出现在表格边框和表格背景之间并让页面背景透出的烦人的1px边框消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58317356/

相关文章:

html - 在 CSS 中缩放一个 div

html - 按钮到最边缘,删除边距

javascript - 您可以将 HTML 元素类名称存储到数组中,然后调用它以在 JQuery 属性中运行吗?

html - ERB/Rails 中关闭 </a> 标记的正确缩进

css - 字体显示未修复 Page Speed Insights 问题

html - 如何保留 :active css style after clicking a link?

javascript - 检测鼠标单击、移动和释放(也称为拖动),而无需在 html5 中拖动对象

Jquery 删除类、添加类

html - CSS关键帧动画重叠

javascript - 如何删除已经使用过的元素?