How can I enlarge a block by the size of the text inside it?

Viewed 19

When I increase the page size, the text in LI slides down, how can I make the block always be larger than the text inside it?

I tried to make a block out of the text, but such attempts were unsuccessful, if you register an exorbitant width in the block property, then everything works (for example, 100000px)

.MainBody{
}
.tree ul {
    padding-top: 20px; position: relative;
    transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
}

.tree li {
    float:left;
    text-align: center;
    list-style-type: none;  
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
}

.tree li::before, .tree li::after{
    content: '';
    position: absolute; top: 0; right: 50%;
    border-top: 1px solid #ccc;
    width: 50%; height: 20px;
}
.tree li::after{
    right: auto; left: 50%;
    border-left: 1px solid #ccc;
}

.tree li:only-child::after, .tree li:only-child::before {
    display: none;
}

.tree li:only-child{ padding-top: 0;}

.tree li:first-child::before, .tree li:last-child::after{
    border: 0 none;
}

.tree li:last-child::before{
    border-right: 1px solid #ccc;
    border-radius: 0 5px 0 0;
    -webkit-border-radius: 0 5px 0 0;
    -moz-border-radius: 0 5px 0 0;
}
.tree li:first-child::after{
    border-radius: 5px 0 0 0;
    -webkit-border-radius: 5px 0 0 0;
    -moz-border-radius: 5px 0 0 0;
}

.tree ul ul::before{
    content: '';
    position: absolute; top: 0; left: 50%;
    border-left: 1px solid #ccc;
    width: 0; height: 20px;
}

.tree li a{
    border: 1px solid #ccc;
    padding: 5px 10px;
    text-decoration: none;
    color: #666;
    font-family: arial, verdana, tahoma;
    font-size: 11px;
    display: inline-block;
    
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    
    transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
}

.tree li a:hover, .tree li a:hover+ul li a {
    background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
}

.tree li a:hover+ul li::after, 
.tree li a:hover+ul li::before, 
.tree li a:hover+ul::before, 
.tree li a:hover+ul ul::before{
    border-color:  #94a0b4;
}

.tree{
    overflow: visible;
    /* font-size: 0.5vw;
    white-space: nowrap; */
}
<html lang="ru">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <meta name="viewport" content="width=device-width">
            <script type="text/javascript" src="jquery.js"></script>
            <link
                href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII="
                rel="icon" type="image/x-icon">
            <link rel="stylesheet" href="style.css">
            <title>Network Monitor</title>
        </head>
        <body class="MainBody">
            <div id="targediv">
                <div class="container">
                    <div class="tree">
                        Дата сейчас: Thu, 07 Apr 22 06:42:54 +0300
                        <ul>
                            <li>Dir-300<br>The IP address, google.com, is alive
                                <ul>
                                    <li>DIR-304<br>The IP address, yandex.ru, is alive
                                        <ul>
                                        </ul>
                                    </li>
                                    <li>DIR-306<br>The IP address, iloveimg.com, is alive
                                        <ul>
                                            <li>DIR-305<br>The IP address, sdfdsgergergrg.net, is dead
                                                <ul>
        
                                                </ul>
                                            </li>
                                            <li>DIR-307<br>The IP address, odnoklassniki.com, is alive<ul>
                                                    <li>DIR-412<br>The IP address, HYPIXEL.NET, is alive<ul>
                                                        </ul>
                                                    </li>
                                                    <li>DIR-415<br>The IP address, gosuslugi.ru, is alive<ul>
        
                                                        </ul>
                                                    </li>
                                                </ul>
                                            </li>
                                            <li>DIR-308<br>The IP address, odnoklassniki.ru, is alive<ul></ul>
                                            </li>
                                        </ul>
                                    </li>
                                </ul>
                            </li>
                            <li>TP-LINK ARCHER C200<br>The IP address, , is dead<ul>
                                    <li>TP-LINK ARCHER C205<br>The IP address, vk.com, is alive<ul></ul>
                                    </li>
                                    <li>TP-LINK ARCHER C210<br>The IP address, https://web.telegram.org, is dead<ul></ul>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </body>
        </html>

0 Answers
Related