Konstantinos Natsios
Konstantinos Natsios

Reputation: 2924

Bootstrap box / border that cant fix it

I have following HTML code with bootstrap with a simple login. I want to make a box behind the login form and to be something like this.

After

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Login Page</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <!-- HOVER CSS -->
    <link href="css/hover-min.css" rel="stylesheet" media="all">

    <link href='https://fonts.googleapis.com/css?family=Poiret+One' rel='stylesheet' type='text/css'>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>
    <div class="logo" class="col-xs-4 col-xs-offset-1">
        <img src="img/tei.png" class="img-responsive" alt="Responsive image">
    </div>

    <!-- NAVBAR -->
    <div class="navbar navbar-default navbar-custom navbar-fixed-top" role="navigation">
        <div class="container container-nav">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle Nav</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>



            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="#">Home</a>

                    </li>

                </ul>
                <ul class="nav navbar-nav navbar-right">

                    <li><a href="#">Contact</a>

                    </li>
                </ul>
            </div>
        </div>
    </div>

    <!-- END NAVBAR -->

    <!-- LOGIN BOX -->
    <div class="container">
        <div class="row">

            <div class="col-md-4 col-md-offset-6">
                <div class="panel panel-default hvr-glow">
                    <div class="panel-heading"> <strong class="">Σύνδεση στην πλατφόρμα Εργαστηρίων</strong>

                    </div>
                    <div class="panel-body">
                        <form class="form-horizontal" role="form" method="post">
                            <div class="form-group">
                                <label for="onoma-xristi" class="col-sm-3 control-label">Όνομα Χρήστη</label>
                                <div class="col-sm-9">
                                    <input name="username" type="text" class="form-control" id="onoma-xristi" placeholder="" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="kwdikos-xristi" class="col-sm-3 control-label">Κωδικός</label>
                                <div class="col-sm-9">
                                    <input name="password" type="password" class="form-control" id="kwdikos-xristi" placeholder="" required="">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-3 col-sm-9">
                                    <div class="checkbox">
                                        <label class="">
                                            <input type="checkbox" class="">Να με θυμάσαι</label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group last">
                                <div class="col-sm-offset-3 col-sm-9">
                                    <button type="submit" class="btn btn-success btn-sm hvr-grow-shadow">Σύνδεση</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- END LOGIN BOX -->

    <!-- HEADER -->
    <div class="header">
        <div class="container">


            <div class="row">
                <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">



                </div>

            </div>
        </div>


    </div>


    <!-- END HEADER -->
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
</body>

</html> 

And live at

Live here

I searched a lot for this border or box but i didnt find anything at all at bootstrap site.

Can anyone guide me of how to make this border and put the login box in the middle of the box and i will play with the margin top.

Thanks a lot for your time!

Upvotes: 2

Views: 339

Answers (1)

hungerstar
hungerstar

Reputation: 21725

Wrap it in a container element. A "Bootstrap" way to do this would be something along the lines of nesting columns.

<div class="container">

    <div class="row"><!-- new -->
        <div class="col-md-12 form-container"><!-- new -->


            <div class="row">
                <div class="col-md-4 col-md-offset-4">

                    <div class="panel panel-default hvr-glow">
                        <!-- rest of your markup -->
                    </div>

                </div>
            </div>

        </div><!-- new -->
    </div><!-- new -->
</div>

Style .form-container as needed; i.e. background-color: white; border-radius: 10px;.

I see you have a custom CSS selector on your navbar's .container element of .container-nav that limits the width of the navbar. You'd have to apply something similar if you wanted what I have above to only be as wide as the navbar.

It looks like this project is a work-in-progress as I foresee issues with your logo and the layout you currently have. So I think any answer you get won't be exactly on point.

Hope this gets you pointed in the right direction though.

Upvotes: 1

Related Questions