Here is the html of the input element I'm trying to make responsive.
I'm trying to make the input responsive for lower screen resolutions like 1200 X 600. Here is the CSS for this HTML.
.demo {
position: relative;
width: 100px;
}
.demo i {
position: relative;
bottom: 14px;
right: 24px;
top: auto;
c cursor: pointer;
}
<div class="row" style="padding: 25px">
<div class=" ">
<p>Date Range</p>
</div>
<div class="col-lg-2 col-md-2 demo" style="top :-7px">
<input type="text" class="form-control" style="cursor: pointer" name="daterange" value="01/01/2018 - 01/01/2050">
<!-- <i class="glyphicon glyphicon-calendar fa fa-calendar"></i> -->
</div>
</div>
Use col-2 instead of col-lg-2 col-md-2
What means it apply to all screen sizes(from xs to lg)
.demo {
position: relative;
width: 100px;
}
.demo i {
position: relative;
bottom: 14px;
right: 24px;
top: auto; c
cursor: pointer;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="row" style="padding: 25px">
<div>
<p>Date Range</p>
</div>
<div class="col-2 demo" style="top :-7px">
<input type="text" class="form-control" style="cursor: pointer" name="daterange" value="01/01/2018 - 01/01/2050">
<!-- <i class="glyphicon glyphicon-calendar fa fa-calendar"></i> -->
</div>
</div>
Related
I had this issue fixed with text-break from bootstrap, but for some reason, something is overriding it and now my text does not wrap at all. I put a code snippet that reproduces the issue. I've tried everything and I am sure I am missing something silly. I'm only typing now because stackoverflow wants me to. You can ignore the next set of random thoughts.
.comment_input{
padding: 5px;
margin: 5px;
border-radius: 8px;
border: none;
width: 100%;
}
.profile-name{
display: flex;
align-items: center;
column-gap: 5px;
}
.profile_image{
width: 30px;
height: 30px;
border-radius: 50%;
}
.post{
margin: 10px auto;
width: 80%;
border-radius: 3px;
background: darkgray;
}
.post_padding{
margin: 5px;
}
.post_comment{
display: flex;
align-items: center;
gap: 5px;
}
.post_top{
display: flex;
justify-content: space-between;
}
.hover:hover {
cursor: pointer;
}
.like-and-comment{
display: flex;
justify-content: space-around;
border-bottom: 1px solid white;
border-top: 1px solid white;
align-items: center;
padding: 5px;
}
.view-more{
display: flex;
justify-content: space-between;
font-size: 14px;
}
.lk{
display: flex;
font-size: 14px;
gap: 5px;
}
.right{
border-left: 1px solid white;
border-bottom: 1px solid white;
border-bottom-left-radius: 30px;
width: 5%;
top: 5px;
position: absolute;
height: 120%;
left: -20px;
}
.reply {
display: flex;
gap: 10px;
}
.reply-body{
word-wrap : break-word;
overflow-wrap: break-word;
}
.user{
/* TODO fix text overflow for when no spaces added*/
background: grey;
padding: 8px;
border-radius: 20px;
/*TODO max variable based on content*/
width: max-content;
word-wrap : break-word;
overflow-wrap: break-word;
}
.like-comment, .reply_comment{
cursor: pointer;
}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.5.0/font/bootstrap-icons.css">
<link href="/static/css/style.css" rel="stylesheet">
<script src="https://js.stripe.com/v3/"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
</head>
<body>
<div class="post">
<script id="counter40">1</script>
<div class="post_padding">
<div class="post_top">
<div class="profile-name">
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<div>
<div id="post_top"> jon </div>
<div id="post_top2" class="location-time"><span class="time">in 3 hours</span><i class="fas fa-globe-americas"></i></div>
</div>
</div>
<div id="three-dots" style="display: block" class="hover">
<div class="dropdown">
<div href="#" data-bs-toggle="dropdown"><i class="bi bi-three-dots"></i></div>
<div class="dropdown-menu">
<div id="post_edit_modal" style="display: block" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_edit_modal(40)">
<i class="bi bi-pencil-square"> Edit</i>
</div>
<div id="post_ban_modal" style="display: block" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_ban_modal(1)">
<i class="bi bi-eye-slash"> Ban</i>
</div>
<div id="post_history_modal" style="display: none;" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_history_modal(1)">
<i class="bi bi-clock-history"> History</i>
</div>
</div>
</div>
</div>
</div>
<!--this is really the post-->
<div class="media ">
<div class="text-break" id="post_body">hi</div>
<img id="media_graphic">
</div>
<!--Finish this, need media link, media article-->
<div class="like-and-comment">
<div class="d-flex align-items-center">
<i id="upvote40" class="fas fa-arrow-up hover" style="color: gray;" onclick="vote(40,1)"></i>
<span id="upvote_count_badge40" class="badge bg-secondary">0</span>
<i id="downvote40" class="fas fa-arrow-down hover" style="color: gray;" onclick="vote(40,0)"></i>
</div>
<div id="post_award_modal" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_award_modal(40)">
<i class="fas fa-award hover"></i>
</div>
<div class="dropdown hover">
<div class="dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-share"></i></div>
<ul class="dropdown-menu">
<p id="post_crosspost_modal" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_crosspost_modal(40)">
<i class="bi bi-signpost-2"> Cross Post</i>
</p>
<p id="copytoclipboard" class="dropdown-item" onclick="copyToClipboard('http://127.0.0.1:5000/post/40')">
<i class="bi bi-clipboard"> Copy Link</i>
</p>
<p id="save_post" class="dropdown-item" onclick="save_post(40)">
<i id="save_post_icon40" class="bi bi-save"> Save</i>
</p>
</ul>
</div>
</div>
<div class="view-more">
<div class="hover" id="load_replies40" onclick="loadReplies(40,0)"></div>
<div class="hover" id="comment_collapse"> 1 comments</div>
</div>
<div class="comment">
<div id="reply_loader40"><!--Append Replies Here-->
<div class="lk">
<script id="counter46">0</script>
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<div style="width: 100%;">
<div class="user">
<div class="reply_author">jon in 6 hours </div>
<div class="reply-body">word-wrap : break-word; overflow-wrap: break-word;word-wrap : break-word; overflow-wrap: break-word;word-wrap : break-word; overflow-wrap: break-word;word-wrap : break-word; overflow-wrap: break-word;</div>
</div>
<div class="reply">
<div class="d-flex align-items-center">
<i id="upvote46" class="fas fa-arrow-up hover" style="color: gray" onclick="vote(46,1)"></i>
<span id="upvote_count_badge46" class="badge bg-secondary">0</span>
<i id="downvote46" class="fas fa-arrow-down hover" style="color: gray" onclick="vote(46,0)"></i>
</div>
<div class="reply_comment" id="reply46">Reply</div>
<div id="post_award_modal" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_award_modal(46)">
<i class="fas fa-award hover"></i>
</div>
</div>
<form id="submit_reply46" style="display: none;" autocomplete="off">
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<input class="comment_input" id="comment_input46" maxlength="1024" name="body" placeholder="Write a comment3" required="" type="text" value="">
<div id="comment_input_error46" class="invalid-feedback"></div>
</form>
<div id="reply_loader46"><!--Nested Replies go here--></div>
</div>
</div>
</div>
<form id="submit_reply" autocomplete="off">
<div class="post_comment">
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<input class="comment_input" id="comment_input40" maxlength="1024" name="body" placeholder="Write a comment" required="" type="text" value="">
<div id="comment_input_error40" class="invalid-feedback"></div>
</div>
</form>
</div>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.min.js" integrity="sha512-LGXaggshOkD/at6PFNcp2V2unf9LzFq6LE+sChH7ceMTDP0g2kn6Vxwgg7wkPP7AAtX+lmPqPdxB47A0Nz0cMQ==" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
</body>
You used max-content for your width in your user container.
The max-content sizing keyword represents the intrinsic maximum width or height of the content. For text content this means that the content will not wrap at all even if it causes overflows. -MDN
You can change that to 100%. You can learn more on max-content here.
.comment_input {
padding: 5px;
margin: 5px;
border-radius: 8px;
border: none;
width: 100%;
}
.profile-name {
display: flex;
align-items: center;
column-gap: 5px;
}
.profile_image {
width: 30px;
height: 30px;
border-radius: 50%;
}
.post {
margin: 10px auto;
width: 80%;
border-radius: 3px;
background: darkgray;
}
.post_padding {
margin: 5px;
}
.post_comment {
display: flex;
align-items: center;
gap: 5px;
}
.post_top {
display: flex;
justify-content: space-between;
}
.hover:hover {
cursor: pointer;
}
.like-and-comment {
display: flex;
justify-content: space-around;
border-bottom: 1px solid white;
border-top: 1px solid white;
align-items: center;
padding: 5px;
}
.view-more {
display: flex;
justify-content: space-between;
font-size: 14px;
}
.lk {
display: flex;
font-size: 14px;
gap: 5px;
}
.right {
border-left: 1px solid white;
border-bottom: 1px solid white;
border-bottom-left-radius: 30px;
width: 5%;
top: 5px;
position: absolute;
height: 120%;
left: -20px;
}
.reply {
display: flex;
gap: 10px;
}
.reply-body {
word-wrap: break-word;
overflow-wrap: break-word;
}
.user {
/* TODO fix text overflow for when no spaces added*/
background: grey;
padding: 8px;
border-radius: 20px;
/*TODO max variable based on content*/
width: 100%;
word-wrap: break-word;
overflow-wrap: break-word;
}
.like-comment,
.reply_comment {
cursor: pointer;
}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.5.0/font/bootstrap-icons.css">
<link href="/static/css/style.css" rel="stylesheet">
<script src="https://js.stripe.com/v3/"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
</head>
<body>
<div class="post">
<script id="counter40">
1
</script>
<div class="post_padding">
<div class="post_top">
<div class="profile-name">
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<div>
<div id="post_top"> jon </div>
<div id="post_top2" class="location-time"><span class="time">in 3 hours</span><i class="fas fa-globe-americas"></i></div>
</div>
</div>
<div id="three-dots" style="display: block" class="hover">
<div class="dropdown">
<div href="#" data-bs-toggle="dropdown"><i class="bi bi-three-dots"></i></div>
<div class="dropdown-menu">
<div id="post_edit_modal" style="display: block" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_edit_modal(40)">
<i class="bi bi-pencil-square"> Edit</i>
</div>
<div id="post_ban_modal" style="display: block" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_ban_modal(1)">
<i class="bi bi-eye-slash"> Ban</i>
</div>
<div id="post_history_modal" style="display: none;" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_history_modal(1)">
<i class="bi bi-clock-history"> History</i>
</div>
</div>
</div>
</div>
</div>
<!--this is really the post-->
<div class="media ">
<div class="text-break" id="post_body">hi</div>
<img id="media_graphic">
</div>
<!--Finish this, need media link, media article-->
<div class="like-and-comment">
<div class="d-flex align-items-center">
<i id="upvote40" class="fas fa-arrow-up hover" style="color: gray;" onclick="vote(40,1)"></i>
<span id="upvote_count_badge40" class="badge bg-secondary">0</span>
<i id="downvote40" class="fas fa-arrow-down hover" style="color: gray;" onclick="vote(40,0)"></i>
</div>
<div id="post_award_modal" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_award_modal(40)">
<i class="fas fa-award hover"></i>
</div>
<div class="dropdown hover">
<div class="dropdown-toggle" data-bs-toggle="dropdown"><i class="fas fa-share"></i></div>
<ul class="dropdown-menu">
<p id="post_crosspost_modal" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_crosspost_modal(40)">
<i class="bi bi-signpost-2"> Cross Post</i>
</p>
<p id="copytoclipboard" class="dropdown-item" onclick="copyToClipboard('http://127.0.0.1:5000/post/40')">
<i class="bi bi-clipboard"> Copy Link</i>
</p>
<p id="save_post" class="dropdown-item" onclick="save_post(40)">
<i id="save_post_icon40" class="bi bi-save"> Save</i>
</p>
</ul>
</div>
</div>
<div class="view-more">
<div class="hover" id="load_replies40" onclick="loadReplies(40,0)"></div>
<div class="hover" id="comment_collapse"> 1 comments</div>
</div>
<div class="comment">
<div id="reply_loader40">
<!--Append Replies Here-->
<div class="lk">
<script id="counter46">
0
</script>
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<div style="width: 100%;">
<div class="user">
<div class="reply_author">jon in 6 hours </div>
<div class="reply-body">word-wrap : break-word; overflow-wrap: break-word;word-wrap : break-word; overflow-wrap: break-word;word-wrap : break-word; overflow-wrap: break-word;word-wrap : break-word; overflow-wrap: break-word;</div>
</div>
<div class="reply">
<div class="d-flex align-items-center">
<i id="upvote46" class="fas fa-arrow-up hover" style="color: gray" onclick="vote(46,1)"></i>
<span id="upvote_count_badge46" class="badge bg-secondary">0</span>
<i id="downvote46" class="fas fa-arrow-down hover" style="color: gray" onclick="vote(46,0)"></i>
</div>
<div class="reply_comment" id="reply46">Reply</div>
<div id="post_award_modal" data-bs-toggle="modal" data-bs-target="#siteModal" onclick="build_award_modal(46)">
<i class="fas fa-award hover"></i>
</div>
</div>
<form id="submit_reply46" style="display: none;" autocomplete="off">
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<input class="comment_input" id="comment_input46" maxlength="1024" name="body" placeholder="Write a comment3" required="" type="text" value="">
<div id="comment_input_error46" class="invalid-feedback"></div>
</form>
<div id="reply_loader46">
<!--Nested Replies go here-->
</div>
</div>
</div>
</div>
<form id="submit_reply" autocomplete="off">
<div class="post_comment">
<img class="profile_image" src="https://robohash.org/006cb570acdab0e0bfc8e3dcb7bb4edf?size=50x50">
<input class="comment_input" id="comment_input40" maxlength="1024" name="body" placeholder="Write a comment" required="" type="text" value="">
<div id="comment_input_error40" class="invalid-feedback"></div>
</div>
</form>
</div>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.min.js" integrity="sha512-LGXaggshOkD/at6PFNcp2V2unf9LzFq6LE+sChH7ceMTDP0g2kn6Vxwgg7wkPP7AAtX+lmPqPdxB47A0Nz0cMQ==" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
</body>
I am creating a login screen with bootstrap and jquery where the access card must be centralized.
The problem is that when the vertical scroll bar appears, scrolling to the top does not display all the content and the facebook button is inaccessible (depending on the height, google's too).
To compensate for the height of the navbar I tested the padding-top on the body and on the parent div, but without success.
I also tried adding a br with clearfix before the card and it didn't work.
#charset "UTF-8";
html, body
{
height: 100%;
width: 100%;
}
body
{
overflow: hidden;
padding-top: 3.5rem;
}
.btn-with-icon
{
position: relative;
}
.btn-with-icon > div
{
background-color: #FFF;
border-radius: 0.15rem;
height: 1.9rem;
left: 0.17rem;
position: absolute;
top: 0.17rem;
width: 1.9rem;
}
.btn-with-icon > div > i
{
height: 1.9rem !important;
width: 1.9rem !important;;
}
.btn-with-icon > div > i::before
{
font-size: 1.5rem;
line-height: 1.9rem !important;
}
.btn-with-icon > div > .fa-facebook::before
{
color: #3B5998;
}
.btn-with-icon > div > .fa-google::before
{
color: #DB4437;
}
.btn-with-icon > span
{
margin-left: 2rem;
}
.input-with-icon > i::before
{
color: #C0C0C0;
font-size: 1rem;
}
.input-with-icon > i
{
font-size: 1.8rem;
position: absolute;
z-index: 1;
}
.input-with-icon > .form-control
{
padding-left: 2rem;
}
.separator
{
color: #C0C0C0;
display: flex;
flex-direction: column;
justify-content: center;
}
.horizontal-rule
{
align-items: center;
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
}
.horizontal-rule::before,
.horizontal-rule::after
{
background: #C0C0C0;
content: '';
flex: 1;
width: 1px;
}
.horizontal-rule::before
{
margin-bottom: 0.5em;
}
.horizontal-rule::after
{
margin-top: 0.5em;
}
.vertical-rule
{
align-items: center;
display: flex;
flex: 1;
flex-direction: row;
justify-content: center;
}
.vertical-rule::before,
.vertical-rule::after
{
background: #C0C0C0;
content: '';
flex: 1;
height: 1px;
}
.vertical-rule::before
{
margin-right: 0.5em;
}
.vertical-rule::after
{
margin-left: 0.5em;
}
.small-text,
.small-text *
{
font-size: 0.8rem;
font-weight: 400;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body class="container-fluid">
<div class="row h-100">
<nav class="navbar navbar-dark bg-dark fixed-top">
<span class="navbar-brand mb-0 h1">navbar</span>
</nav>
<div class="col-12 h-100 d-flex justify-content-center align-items-center overflow-auto">
<div class="card">
<div class="card-body">
<form method="post" action="#">
<div class="form-row">
<div class="form-group col-12">
<button type="button" class="btn btn-secondary btn-block text-left btn-with-icon">
<div>
<i class="fa fa-facebook fa-fw"></i>
</div>
<span>Login with Facebook</span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<button type="button" class="btn btn-secondary btn-block text-left btn-with-icon">
<div>
<i class="fa fa-google fa-fw"></i>
</div>
<span>Login with Google</span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 separator">
<span class="vertical-rule">OR</span>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 input-with-icon">
<i class="fa fa-at fa-fw"></i>
<input type="email" placeholder="e-mail" class="form-control">
</div>
</div>
<div class="form-row">
<div class="form-group col-12 input-with-icon">
<i class="fa fa-lock fa-fw"></i>
<input type="password" placeholder="password" class="form-control">
Forgotten password
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<button type="submit" class="btn btn-success btn-block">
<span class="fa fa-check"></span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 text-center small-text">
Sign in
</div>
</div>
<div class="form-row">
<div class="form-group col-6 mb-0 small-text">
Terms
</div>
<div class="form-group col-6 mb-0 text-right small-text">
Privacy policy
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
I've removed align-items-center from the containing div and added m-auto to the card.
#charset "UTF-8";
html, body
{
height: 100%;
width: 100%;
}
body
{
overflow: hidden;
padding-top: 3.5rem;
}
.btn-with-icon
{
position: relative;
}
.btn-with-icon > div
{
background-color: #FFF;
border-radius: 0.15rem;
height: 1.9rem;
left: 0.17rem;
position: absolute;
top: 0.17rem;
width: 1.9rem;
}
.btn-with-icon > div > i
{
height: 1.9rem !important;
width: 1.9rem !important;;
}
.btn-with-icon > div > i::before
{
font-size: 1.5rem;
line-height: 1.9rem !important;
}
.btn-with-icon > div > .fa-facebook::before
{
color: #3B5998;
}
.btn-with-icon > div > .fa-google::before
{
color: #DB4437;
}
.btn-with-icon > span
{
margin-left: 2rem;
}
.input-with-icon > i::before
{
color: #C0C0C0;
font-size: 1rem;
}
.input-with-icon > i
{
font-size: 1.8rem;
position: absolute;
z-index: 1;
}
.input-with-icon > .form-control
{
padding-left: 2rem;
}
.separator
{
color: #C0C0C0;
display: flex;
flex-direction: column;
justify-content: center;
}
.horizontal-rule
{
align-items: center;
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
}
.horizontal-rule::before,
.horizontal-rule::after
{
background: #C0C0C0;
content: '';
flex: 1;
width: 1px;
}
.horizontal-rule::before
{
margin-bottom: 0.5em;
}
.horizontal-rule::after
{
margin-top: 0.5em;
}
.vertical-rule
{
align-items: center;
display: flex;
flex: 1;
flex-direction: row;
justify-content: center;
}
.vertical-rule::before,
.vertical-rule::after
{
background: #C0C0C0;
content: '';
flex: 1;
height: 1px;
}
.vertical-rule::before
{
margin-right: 0.5em;
}
.vertical-rule::after
{
margin-left: 0.5em;
}
.small-text,
.small-text *
{
font-size: 0.8rem;
font-weight: 400;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body class="container-fluid">
<div class="row h-100">
<nav class="navbar navbar-dark bg-dark fixed-top">
<span class="navbar-brand mb-0 h1">navbar</span>
</nav>
<div class="col-12 h-100 d-flex justify-content-center overflow-auto">
<div class="card m-auto">
<div class="card-body">
<form method="post" action="#">
<div class="form-row">
<div class="form-group col-12">
<button type="button" class="btn btn-secondary btn-block text-left btn-with-icon">
<div>
<i class="fa fa-facebook fa-fw"></i>
</div>
<span>Login with Facebook</span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<button type="button" class="btn btn-secondary btn-block text-left btn-with-icon">
<div>
<i class="fa fa-google fa-fw"></i>
</div>
<span>Login with Google</span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 separator">
<span class="vertical-rule">OR</span>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 input-with-icon">
<i class="fa fa-at fa-fw"></i>
<input type="email" placeholder="e-mail" class="form-control">
</div>
</div>
<div class="form-row">
<div class="form-group col-12 input-with-icon">
<i class="fa fa-lock fa-fw"></i>
<input type="password" placeholder="password" class="form-control">
Forgotten password
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<button type="submit" class="btn btn-success btn-block">
<span class="fa fa-check"></span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 text-center small-text">
Sign in
</div>
</div>
<div class="form-row">
<div class="form-group col-6 mb-0 small-text">
Terms
</div>
<div class="form-group col-6 mb-0 text-right small-text">
Privacy policy
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
For now i added a new Class to prevent the Card from expanding to much with a set max-height, Class in HTMl and the new CSS are marked with comments. I will try to look further into this and find out exactly why this happened but you can try this out and see if it fixes the issue on your page. In the Snippet it does.
#charset "UTF-8";
html, body
{
height: 100%;
width: 100%;
}
body
{
overflow: hidden;
padding-top: 3.5rem;
}
.btn-with-icon
{
position: relative;
}
.btn-with-icon > div
{
background-color: #FFF;
border-radius: 0.15rem;
height: 1.9rem;
left: 0.17rem;
position: absolute;
top: 0.17rem;
width: 1.9rem;
}
.btn-with-icon > div > i
{
height: 1.9rem !important;
width: 1.9rem !important;;
}
.btn-with-icon > div > i::before
{
font-size: 1.5rem;
line-height: 1.9rem !important;
}
.btn-with-icon > div > .fa-facebook::before
{
color: #3B5998;
}
.btn-with-icon > div > .fa-google::before
{
color: #DB4437;
}
.btn-with-icon > span
{
margin-left: 2rem;
}
.input-with-icon > i::before
{
color: #C0C0C0;
font-size: 1rem;
}
.input-with-icon > i
{
font-size: 1.8rem;
position: absolute;
z-index: 1;
}
.input-with-icon > .form-control
{
padding-left: 2rem;
}
.separator
{
color: #C0C0C0;
display: flex;
flex-direction: column;
justify-content: center;
}
.horizontal-rule
{
align-items: center;
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
}
.horizontal-rule::before,
.horizontal-rule::after
{
background: #C0C0C0;
content: '';
flex: 1;
width: 1px;
}
.horizontal-rule::before
{
margin-bottom: 0.5em;
}
.horizontal-rule::after
{
margin-top: 0.5em;
}
.vertical-rule
{
align-items: center;
display: flex;
flex: 1;
flex-direction: row;
justify-content: center;
}
.vertical-rule::before,
.vertical-rule::after
{
background: #C0C0C0;
content: '';
flex: 1;
height: 1px;
}
.vertical-rule::before
{
margin-right: 0.5em;
}
.vertical-rule::after
{
margin-left: 0.5em;
}
.small-text,
.small-text *
{
font-size: 0.8rem;
font-weight: 400;
}
/*This is the new CSS*/
.display-area{
max-height: 80%;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body class="container-fluid">
<div class="row h-100">
<nav class="navbar navbar-dark bg-dark fixed-top">
<span class="navbar-brand mb-0 h1">navbar</span>
</nav>
<div class="col-12 h-100 d-flex justify-content-center align-items-center overflow-auto">
<!-- added a new class here -->
<div class="card display-area">
<div class="card-body">
<form method="post" action="#">
<div class="form-row">
<div class="form-group col-12">
<button type="button" class="btn btn-secondary btn-block text-left btn-with-icon">
<div>
<i class="fa fa-facebook fa-fw"></i>
</div>
<span>Login with Facebook</span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<button type="button" class="btn btn-secondary btn-block text-left btn-with-icon">
<div>
<i class="fa fa-google fa-fw"></i>
</div>
<span>Login with Google</span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 separator">
<span class="vertical-rule">OR</span>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 input-with-icon">
<i class="fa fa-at fa-fw"></i>
<input type="email" placeholder="e-mail" class="form-control">
</div>
</div>
<div class="form-row">
<div class="form-group col-12 input-with-icon">
<i class="fa fa-lock fa-fw"></i>
<input type="password" placeholder="password" class="form-control">
Forgotten password
</div>
</div>
<div class="form-row">
<div class="form-group col-12">
<button type="submit" class="btn btn-success btn-block">
<span class="fa fa-check"></span>
</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-12 text-center small-text">
Sign in
</div>
</div>
<div class="form-row">
<div class="form-group col-6 mb-0 small-text">
Terms
</div>
<div class="form-group col-6 mb-0 text-right small-text">
Privacy policy
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
I have two div's that I want to have equal height. The left div has dynamic content which can expand vertically with any number of inner div's. The right div has one inner div that needs to stay at the top and still be visible no matter how far you scroll down. Please look at this codepen
#shipping_policies {
border: 1px solid #000000;
padding: 5px;
}
#shipping_policies a {
display: block;
font-size: .9em;
text-decoration: underline;
}
.checkout .card-header {
background-color: #f2f2f2 !important;
}
.checkout button {
color: #000;
font-size: 0.6em;
}
.square1 {
height: 100px;
width: 100px;
background-color: red;
line-height: 100px;
text-align: center;
}
.square1 p {
color: #FFFFFF;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container mt-5 h-auto">
<div class="" style="">
<div class="col-6 border-danger float-left d-inline-block mr-1" style="background-color: #ffffff;">
<div style="width: 150px;" class="py-2 d-inline">
<div class="float-left">
<img src="https://via.placeholder.com/228x150" alt="" class="mt-2 mb-5" /><br>
<a class="mt-4" style="border-radius: 0; width: 150px; margin-bottom: 10px;" id="del-item" href="#">X REMOVE</a>
</div>
<div class="float-left ml-3 mt-1">
<p class="px-0 mb-0">short_desc</p>
<p class="px-0 mb-0">UOM</p>
<label for="quantity" style="margin-bottom: 0; font-weight: bold; margin-top: 20px;">QTY</label><br>
<input type="text" class="quantity" name="quantity" value="1">
</div>
</div>
<div style="position: absolute; right: 10px; bottom: 1px;">
<p class="mb-0" style="font-weight: bold; font-size: 1.1em; color: #990000;">$399.99</p>
</div>
</div>
<div class="col-6 border-danger float-left d-inline-block mr-1" style="background-color: #ffffff;">
<div style="width: 150px;" class="py-2 d-inline">
<div class="float-left">
<img src="https://via.placeholder.com/228x150" alt="" class="mt-2 mb-5" /><br>
<a class="mt-4" style="border-radius: 0; width: 150px; margin-bottom: 10px;" id="del-item" href="#">X REMOVE</a>
</div>
<div class="float-left ml-3 mt-1">
<p class="px-0 mb-0">short_desc</p>
<p class="px-0 mb-0">UOM</p>
<label for="quantity" style="margin-bottom: 0; font-weight: bold; margin-top: 20px;">QTY</label><br>
<input type="text" class="quantity" name="quantity" value="1">
</div>
</div>
<div style="position: absolute; right: 10px; bottom: 1px;">
<p class="mb-0" style="font-weight: bold; font-size: 1.1em; color: #990000;">$399.99</p>
</div>
</div>
</div>
<div class="" style="">
<div class="col-4 border-danger float-left ml-4" style="background-color: #f2f2f2; border-radius: 4px;">
<div class="w-100 mt-2">
<span>Subtotal</span>
<p class="float-right">$399.99</p>
</div>
<div class="w-100 mt-4">
<h4 style="font-weight: bold; margin-bottom: 0">Estimated Total</h4>
<p class="float-right" style="font-size: large; font-weight: bold;">$399.99</p>
<p class="" style="font-size: smaller">Tax Calculated at Checkout</p>
</div>
<hr style="height: 2px; color: #000; background: #000;" />
<div class="w-100">
<input class="w-100" style="height: 40px;" type="text" id="promo" name="promo" placeholder="Enter Promo Code" />
<button style="position: absolute; right: 8%; bottom: 34%; background-color: #0066CC; color: #FFFFFF;">Apply Now</button>
</div>
<hr style="height: 5px; color: #000; background: #0066CC;" />
<a class="w-100 mb-2 btn" style="background-color: #febd69;" href="http://groves.local/product/checkout">CHECKOUT</a>
</div>
<div class="float-right" style="margin-right: 15%; margin-top: 2%; width: 340px;">
<h5 style="font-weight: bold;">Shipping & Policies</h5>
<div id="shipping_policies">
Shipping
Policies
</div>
</div>
</div>
<div>
This code snippet is where I have gotten so far any help is greatly appreciated.
Added a class .fixed with position:fixed to the element that should stay on one place, also fixed your html layout. See https://codepen.io/anon/pen/joYmvV?editors=1100
Update:
You can also add position:sticky instead of position:fixed - It produces a nice effect. See the updated code https://codepen.io/anon/pen/joYmvV?editors=1100
Use position fixed. Position fixed makes it so that an element stays at it's specified place even if the user scrolls up or down.
The search box is too small in terms of width on the bar(used bar instead of navbar in order to customize it).How can I make the search bar broader?Plus, how can I change the height of the search box with respect to the top of the screen?
<div class="bar navbar-inverse navbar-fixed-top">
<div class="container">
<span id="logo">
XYZ
</span>
<span class="col-xs-5 right-inner-addon has-feedback">
<form class="form-inline" role="form">
<div class="form-group has-feedback">
<label class="control-label" for="inputSuccess4"></label>
<input type="text" class="form-control" id="inputSuccess4">
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
</form>
</span>
</div>
</div>
.right-inner-addon {
padding-top: 5px;
padding-left:30px;
position: relative;
}
.right-inner-addon input {
width: 500px;
height: 30px;
padding: 0px 5px;
}
.right-inner-addon i {
position: absolute;
right: 0px;
padding: 10px 6px;
pointer-events: none;
}
In the styling for form-control add width= *insert width here*. That should work
I want to have a clickable search icon inside the search box but the icon is not visible in the search box.The class icon-search does not seem to be working.I used bar instead of navbar for customizing its height and its working fine.Plus,how should I customize the height of the search box?
<div class="bar navbar-inverse navbar-fixed-top">
<div class="container">
<span id="logo">
XYZ
</span>
<span class="col-xs-5 right-inner-addon ">
<i class="icon-search"></i>
<input type="text" class="form-control" />
</span>
</div>
</div>
.right-inner-addon {
padding-top: 6px;
position: relative;
}
.right-inner-addon input {
padding-right: 30px;
}
.right-inner-addon i {
position: absolute;
right: 0px;
padding: 10px 6px;
pointer-events: none;
}
.bar{
min-width: 800px;
background-color: #563d7c;
width:100%;
height:43px;
box-shadow: 0px 3px 25px #888888;
position: fixed;
}
If you are using Bootstrap 3 you can try using the following code: http://jsfiddle.net/D2RLR/5888/
<div class="bar navbar-inverse navbar-fixed-top">
<div class="container">
<span id="logo">
XYZ
</span>
<span class="col-xs-5 right-inner-addon ">
<div class="input-group">
<input type="text" name="search" id="search" class="form-control" placeholder="Test" />
<span class="input-group-addon" for="search">
<i class="glyphicon glyphicon-search"></i>
</span>
</div>
</span>
</div>
</div>