Search code examples
javascripthtmlcssbootstrap-4s7-1200

Having trouble with Bootstrap


I've recently started using bootstrap to make a website functioning for both computer and mobile phones/tablets. While it scales everything nicely in the browser, when I resize my browser window, some words disappear in my interface. How can I make it so that my text doesn't disappear and stay in their respective rectangles?

I'm running this webpage on a Siemens S7-1200 PLC. I have made a json file that fetches data from the PLC which I represent on my website. When I try it on my phone however, some of the text disappears. The following Image represents how my page looks like on a web browser on my laptop:enter image description here

When I resize my browser it looks like the following: enter image description here

Notice the arrow I've added, the arrow points towards the '1' that is next to the text that says 'Mixer 1'. Excuse my english, it's not my mother tongue.

My HTML code:

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- title -->
    <title>Main Page</title>
    <!-- scripts -->

    <!-- css -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="css/custom.css">
    <link href="https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/css/bootstrap4-toggle.min.css" rel="stylesheet">  


</head>

<nav class="navbar navbar-expand-md">
    <a class="navbar-brand" href="#">
        <img src="img/logo.png">
    </a>
    <button class="navbar-toggler navbar-dark" type="button" data-toggle="collapse" data-target="#main-navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="main-navigation">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="main.html"><h2>Main</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="motoren.html"><h2>Motoren</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="verwarming.html"><h2>Verwarming</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="io1.html"><h2>DI</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="io2.html"><h2>DQ</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="io3.html"><h2>AI</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="alarm.html"><h2>Alarm</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="diagnostics.html"><h2>Diagnostics</h2></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="parameters.html"><h2>Parameters</h2></a>
            </li>
        </ul>
    </div>
</nav>

<header class="page-header header container-fluid">
    <div class="overlay">
        <div class="customTable">
            <div class="container-fluid">
                <div class="container-fluid">
                    <!-- Control the column width, and how they should appear on different devices -->
                    <div class="row">
                        <div class="col-pixel-width-100">Overzicht</div>
                        <div class="col" id="ovznormaal">Normaal</div>
                        <div class="col" id="ovzengsave">Energy Save</div>
                        <div class="col" id="ovzhyg">Hygieniseren</div>
                        <div class="col" id="ovzhygdone">Hygieniseren Klaar</div>
                        <div class="col" id="ovzdrleeg">Leeg Draaien</div>
                    </div>
                    <br>

                    <div class="row">
                        <div class="col-pixel-width-100">Motoren</div>
                        <div class="col" id="mix1">Mixer 1</div>
                        <div class="col" id="mix2">Mixer 2 (EC100)</div>
                        <div class="col" id="ventil">Ventilator</div>
                        <div class="col" id="percent"><p id="percnum">0 %</p></div>
                    </div>
                    <br>

                    <div class="row">
                        <div class="col-pixel-width-100">Verwarming</div>
                        <div class="col">Product Temperatuur</div>
                        <div class="col"><p id="prodTemp">000.0 C</p></div>
                        <div class="col">Mat 1 Temperatuur</div>
                        <div class="col"><p id="m1temp">000.0 C</p></div>
                    </div>
                    <br>

                    <div class="row">
                        <div class="col-pixel-width-100">IO</div>
                        <div class="col">Mat 2 Temperatuur</div>
                        <div class="col"><p id="m2temp">000.0 C</p></div>
                        <div class="col">Mat 3 Temperatuur</div>
                        <div class="col"><p id="m3temp">000.0 C</p></div>
                    </div>
                    <br>

                    <div class="row">
                        <div class="col-pixel-width-100">Alarmen</div>
                        <div class="col">Verwarming Matten</div>
                        <div id="mt1" class="col">Mat 1</div>
                        <div id="mt2" class="col">Mat 2</div>
                        <div id="mt3"class="col">mat 3</div>
                        <!--<div class="col"></div>-->
                    </div>
                    <br>

                    <div class="row">
                        <div class="col-pixel-width-100">Diagnostics</div>
                        <div class="col">Programma Keuze</div>
                        <div id="kort" class="col"><p id="shortprog">Kort 0000 Min</p></div>
                        <div id="lang" class="col"><p id="longprog">Lang 0000 Min</p></div>
                    </div>
                    <br>

                    <div class="row">
                        <div class="col-pixel-width-100">Parameters</div>
                        <div class="col">Operationele stand</div>
                        <div class="col">
                            <div class="switchcontainer">
                                <form>
                                    <input type="submit" value="Auto">
                                    <input type="hidden" name='"2_HMI".AUTOTEST' value="0">
                                </form>
                                <form>
                                    <input type="submit" value="Handmatig">
                                    <input type="hidden" name='"2_HMI".AUTOTEST' value="1">
                                </form>
                                <!--<button id="Auto">Auto</button>
                                <button id="Handmatig">Handmatig</button>-->
                            </div>
                        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>

<body>
    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/js/bootstrap4-toggle.min.js"></script>
    <script type="text/javascript" src="js/custom/main.js"></script>
</body>

</html>

My CSS:

body {
  padding: 0;
  margin: 0;
  background: #f2f6e9;
}
/*--- navigation bar ---*/
.navbar {
  background:#6ab446;
}
.nav-link,
.navbar-brand {
  color: #fff;
  cursor: pointer;
}
.nav-link {
  margin-right: 1em !important;
}
.nav-link:hover {
  color: #000;
}
.navbar-collapse {
  justify-content: flex-end;
}

.header {
  background-image: url('../img/test.png');
  background-size: cover;
  background-position: center;
  position: relative;
}

.overlay {
  position: absolute;
  min-height: 100%;
  min-width: 100%;
  left: 0;
  top: 0;
  background: rgba(0, 0, 0, 0.6);
}

.customTable {
    padding-top: 8%;
    padding-left: 2%;
    width: 98%;
}

.col {
    height: 100px;
    font-size: 25;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    line-height: 98px;
    border: 1px solid black;
    background-color:lightgray;
}

.col-pixel-width-100 { 
    font-size: 40;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    line-height: 100px;
    flex: 0 0 15%; 
    background-color:grey;
}

#Auto {
    width: 180px;
    height: 100%;
}
#Handmatig {
    width: 180px;
    height: 100%;
}

I hope someone can give my some tips, I'm kind of a beginner to CSS/HTML/JS.


Solution

  • Your <DIV> text is wrapping into the box below it, add white-space: nowrap to your CSS for the DIVs under .col {} and .col-pixel-width-100 {}

    .col {
        height: 100px;
        font-size: 25;
        font-weight: bold;
        text-align: center;
        vertical-align: middle;
        line-height: 98px;
        border: 1px solid black;
        background-color:lightgray;
        white-space: nowrap;
    }
    
    .col-pixel-width-100 { 
        font-size: 40;
        font-weight: bold;
        text-align: center;
        vertical-align: middle;
        line-height: 100px;
        flex: 0 0 15%; 
        background-color:grey;
        white-space: nowrap;
    }