I want to position the list under the input, what is wrong by my css?
See Example
In this example the nested menu is positioned too far to the left and a little too high (it should start vertically where the containing menu ends).
.combobox-wrapper {
position: relative;
width: 20em;
min-height: 1.5em;
display: flex;
align-items: center;
width: 100%;
display: flex;
flex-direction: row;
}
.combobox-label {
width: 50%;
padding-top: 0.5em;
}
.combobox-input {
font-size: 16px;
font-weight: normal;
height: 30px;
padding: 4px 10px;
width: 50%;
}
.combobox-options {
position: absolute;
margin: 0;
padding: 0;
list-style: none;
max-height: 15em;
overflow-y: auto;
left: 0;
top: calc(100% + 0.25em);
z-index: 100;
display: block;
}
.combobox-option {
padding: 0.25em 0.5em;
cursor: pointer;
position: relative;
}
<div class="combobox-wrapper">
<label for="combobox-input" class="combobox-label">
Countries
</label>
<input id="combobox-input" />
<ul id="combobox-listbox" role="listbox" class="combobox-options">
<li tabindex="0" id=":rl:-BZ" role="option" value="BZ" class="combobox-option highlighted"><span>Belize</span></li>
<li tabindex="0" id=":rl:-BJ" role="option" value="BJ" class="combobox-option"><span>Benin</span></li>
</ul>
</div>
```
I don't know if you mean this or not but you can try this:
index.html
<div class="combobox-wrapper">
<div>
<label for="combobox-input" class="combobox-label">
Countries
</label>
<input id="combobox-input" />
</div>
<div>
<ul id="combobox-listbox" role="listbox" class="combobox-options">
<li tabindex="0" id=":rl:-BZ" role="option" value="BZ"
class="combobox-option highlighted"><span>Belize</span></li>
<li tabindex="0" id=":rl:-BJ" role="option" value="BJ"
class="combobox-option"><span>Benin</span></li>
<li tabindex="0" id=":rl:-BM" role="option" value="BM"
class="combobox-option"><span>Bermuda</span></li>
<li tabindex="0" id=":rl:-BT" role="option" value="BT"
class="combobox-option"><span>Bhutan</span></li>
<li tabindex="0" id=":rl:-BO" role="option" value="BO"
class="combobox-option"><span>Bolivia</span></li>
<li tabindex="0" id=":rl:-BA" role="option" value="BA"
class="combobox-option"><span>Bosnia and Herzegovina</span></li>
<li tabindex="0" id=":rl:-BW" role="option" value="BW"
class="combobox-option"><span>Botswana</span></li>
<li tabindex="0" id=":rl:-BV" role="option" value="BV"
class="combobox-option"><span>Bouvet Island</span></li>
<li tabindex="0" id=":rl:-BR" role="option" value="BR"
class="combobox-option"><span>Brazil</span></li>
<li tabindex="0" id=":rl:-IO" role="option" value="IO"
class="combobox-option"><span>British Indian Ocean Territory</span></li>
<li tabindex="0" id=":rl:-BN" role="option" value="BN"
class="combobox-option"><span>Brunei Darussalam</span></li>
<li tabindex="0" id=":rl:-BG" role="option" value="BG"
class="combobox-option"><span>Bulgaria</span></li>
</ul>
</div>
</div>
style.css
.combobox-wrapper {
position: relative;
width: 20em;
min-height: 1.5em;
display: flex;
align-items: center;
border-radius: var(--form-field-border-radius);
outline: none;
background-color: white;
width: 100%;
display: flex;
flex-direction: column;
}
.combobox-label {
color: var(--color-text-dark-gray);
padding-top: 0.5em;
}
.combobox-input {
font-size: 16px;
font-weight: normal;
color: #4d4d4d;
background: #ffffff;
border: 1px solid #828995;
height: 30px;
padding: 4px 10px;
width: 50%;
}
.combobox-options {
list-style: none;
max-height: 15em;
overflow-y: auto;
border: 0.05em solid var(--color-bg-gray);
border-radius: var(--form-field-border-radius);
left: 0;
top: calc(100% + 0.25em);
background-color: var(--color-white);
z-index: 100;
display: block;
}
.combobox-option {
padding: 0.25em 0.5em;
cursor: pointer;
}
Related
I'm trying to move my text up so that it's not in the center of the page. I would like to move the text "GET YOUR LICENSE & PERMIT BONDS FAST & EASY" up a little bit on my split-screen. I tried top and bottom px but that isn't working. I just would like it to move up a little bit. Any help will be greatly appreciated!
body {
margin:0;
padding: 0;
font-family: "Open+Sans", sans-serif;
}
.navbar {
border-bottom: 2px solid #0C133C;
}
#nav {
background-color: #fff;
color: white;
width: 100%;
}
.nav {
float: right;
text-align: left;
margin: 0;
}
.nav > li {
display:Inline-block;
padding: 20px 50px 10px 9px;
}
.nav > li a {
text-decoration: none;
color: #0C133C;
font-size: 18px;
border-bottom: 3px solid transparent;
}
.clearer {
clear:both;
}
.subnav class{
margin: 0;
position:relative;
}
.subnav > div a {
text-decoration: none;
color: #0C133C;
font-size: 18px;
padding: 20px 30px 10px 9px;
}
.logo {
margin-top: 1rem;
}
.subnav {
display: flex;
justify-content: space-between;
align-items: center;
margin-right: 1rem;
}
.split {
height: 70%;
width: 50%;
position: fixed;
z-index: 1;
top: -50;
overflow-x: hidden;
padding-top: 20px;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.left {
left: 0;
background-color: #282C41;
color: white;
margin-top: .5rem;
font-size: 15px;
}
h1 {
line-height: 1.2;
font-size: 40px;
bottom: 20px;
}
.right {
right: 0;
background-color: #CDCDCD;
margin-top: .5rem;
font-size: 18px;
}
input[type=text], select {
position: relative;
left: 140px;
width: 50%;
padding: 12px 20px;
margin: 3px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.button: {
position: relative;
left: 140px;
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Navbar</title>
<link rel="stylesheet" href="styles.css"
</head>
<body>
<div class="navbar">
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Sign In</a>
</li>
</ul>
<div class="clearer"></div>
</div>
<subnav class="subnav subnav-light bg-light">
<img src="universallogo.jpg" class="logo"/>
<div class="container-fluid">
<a class="subnav=brand" href="#">
<a class="nav-link active" aria-current="page" href="#">Bonds</a>
</a>
<a class="nav-link active" aria-current="page" href="#">Report a Claim</a>
<a class="nav-link active" aria-current="page" href="#">About Us</a>
<a class="nav-link active" aria-current="page" href="#">Search</a>
</div>
</subnav>
<div class="split left">
<div class="centered">
<h1>GET YOUR LICENSE & PERMIT BONDS FAST & EASY</h1>
<p>We provide our Customers with a fast, easy, and secure way to get bonded. Get your Free Quote in minutes.
</p>
</div>
</div>
<div class="split right">
<form name="form1" id="form1" action="/action_page.php">
<select name="subject" id="subject">
<option value="" selected="selected">Select Your State</option>
<option value="California">California</option>
<option value="California">Illinois</option>
<option value="California">Michigan</option>
<option value="California">Ohio</option>
</select>
<br><br>
<select name="topic" id="topic">
<option value="" selected="selected">Who is requring the bond</option>
</select>
<br><br>
<select name="chapter" id="chapter">
<option value="" selected="selected">What jurisdiction is requring the bond</option>
</select>
<br><br>
<select name="chapter" id="chapter">
<option value="" selected="selected">Select Your Bond</option>
</select>
<br><br>
</form>
<form action="/action_page.php">
<input type="text" id="date" name="startdate" placeholder="Effective Start Date">
<br><br>
<input type="text" id="email" name="typeemail" placeholder=" Type E-mail">
</form>
<button type="button">Click Me!</button>
</div>
</body>
</html>
You are having this issue because of the top: 50% style applied to the centered class style applied to the parent container of the <h1> element. I've applied the following changes to avoid this issue and allow you to apply the manual margin-top style.
.centered{
position: absolute;
/* I disabled the style below. */
/* top: 50%; */
/* Added the following style for spacing from above. */
margin-top: 125px;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
Change the margin-top value defined in the centered class style to set the position of the corresponding <h1> element. Below is the executable snippet.
body {
margin: 0;
padding: 0;
font-family: "Open+Sans", sans-serif;
}
.navbar {
border-bottom: 2px solid #0C133C;
}
#nav {
background-color: #fff;
color: white;
width: 100%;
}
.nav {
float: right;
text-align: left;
margin: 0;
}
.nav>li {
display: Inline-block;
padding: 20px 50px 10px 9px;
}
.nav>li a {
text-decoration: none;
color: #0C133C;
font-size: 18px;
border-bottom: 3px solid transparent;
}
.clearer {
clear: both;
}
.subnav class {
margin: 0;
position: relative;
}
.subnav>div a {
text-decoration: none;
color: #0C133C;
font-size: 18px;
padding: 20px 30px 10px 9px;
}
.logo {
margin-top: 1rem;
}
.subnav {
display: flex;
justify-content: space-between;
align-items: center;
margin-right: 1rem;
}
.split {
height: 70%;
width: 50%;
position: fixed;
z-index: 1;
top: -50;
overflow-x: hidden;
padding-top: 20px;
}
.centered{
position: absolute;
/* I disabled the style below. */
/* top: 50%; */
/* Added the following style for spacing from above. */
margin-top: 125px;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.left {
left: 0;
background-color: #282C41;
color: white;
margin-top: .5rem;
font-size: 15px;
}
h1 {
line-height: 1.2;
font-size: 40px;
bottom: 20px;
}
.right {
right: 0;
background-color: #CDCDCD;
margin-top: .5rem;
font-size: 18px;
}
input[type=text],
select {
position: relative;
left: 140px;
width: 50%;
padding: 12px 20px;
margin: 3px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.button: {
position: relative;
left: 140px;
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Navbar</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="navbar">
<ul class="nav">
<li class="nav-item"><a class="nav-link active" aria-current="page" href="#">Contact Us</a></li>
<li class="nav-item"><a class="nav-link active" aria-current="page" href="#">Sign In</a></li>
</ul>
<div class="clearer"></div>
</div>
<subnav class="subnav subnav-light bg-light"><img src="universallogo.jpg" class="logo" />
<div class="container-fluid"><a class="subnav=brand" href="#"><a class="nav-link active" aria-current="page" href="#">Bonds</a></a><a class="nav-link active" aria-current="page" href="#">Report a Claim</a><a class="nav-link active" aria-current="page" href="#">About Us</a><a class="nav-link active" aria-current="page" href="#">Search</a></div>
</subnav>
<div class="split left">
<div class="centered">
<h1>GET YOUR LICENSE & PERMIT BONDS FAST & EASY</h1>
<p>We provide our Customers with a fast, easy, and secure way to get bonded. Get your Free Quote in minutes. </p>
</div>
</div>
<div class="split right">
<form name="form1" id="form1" action="/action_page.php"><select name="subject" id="subject">
<option value="" selected="selected">Select Your State</option>
<option value="California">California</option>
<option value="California">Illinois</option>
<option value="California">Michigan</option>
<option value="California">Ohio</option>
</select><br><br><select name="topic" id="topic">
<option value="" selected="selected">Who is requring the bond</option>
</select><br><br><select name="chapter" id="chapter">
<option value="" selected="selected">What jurisdiction is requring the bond</option>
</select><br><br><select name="chapter" id="chapter">
<option value="" selected="selected">Select Your Bond</option>
</select><br><br></form>
<form action="/action_page.php"><input type="text" id="date" name="startdate" placeholder="Effective Start Date"><br><br><input type="text" id="email" name="typeemail" placeholder=" Type E-mail"></form><button type="button">Click Me!</button>
</div>
</body>
</html>
I'm creating a display that mimics how a directory of files might be displayed in a file browser or IDE (e.g. Sublime, VSCode, etc..)
body {
font-size: 16px;
font-family: monospace;
}
.tree {
box-sizing: border-box;
min-width: 200px;
width: 200px;
height: 400px;
margin: 0;
padding: 20px 0;
overflow-x: scroll;
white-space: nowrap;
background-color: #ebedef;
}
.tree-node {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: stretch;
justify-content: flex-start;
height: 18px;
padding: 6px 0;
cursor: pointer;
}
.tree-node:hover {
background-color: #dbdde0;
}
.tree-node span {
line-height: 18px;
}
.tree-node svg {
margin-right: 7px;
}
<body>
<ul class="tree">
<li style="padding-left: 15px;" tabindex="0" class="tree-node tree-node--directory">
<span>/</span>
</li>
<li style="padding-left: 30px;" tabindex="0" class="tree-node tree-node--directory">
<span>dir1</span>
</li>
<li style="padding-left: 45px;" tabindex="0" class="tree-node tree-node--directory">
<span>dir2</span>
</li>
<li style="padding-left: 60px;" tabindex="0" class="tree-node tree-node--file">
<span>transformations.js</span>
</li>
<li style="padding-left: 45px;" tabindex="0" class="tree-node tree-node--file">
<span>foo.js</span>
</li>
<li style="padding-left: 30px;" tabindex="0" class="tree-node tree-node--file">
<span>package.json</span>
</li>
</ul>
</body>
It uses an inline padding-left on each element to indent it as needed to form the file structure.
As you hover over a directory or file (e.g. transformations.js), it is highlighted with a background color
The whole display is constrained to 200px width, but it scrolls to accommodate longer names.
The problem
However, when scrolling, the highlight does not extend to the full width*. I've tried various combination of nesting divs and playing with the width, but no luck. How can I accomplish this?
I'm having trouble with the fact that
Each item / line has a different width
Each item / line has a custom padding-left set as an offset
I'm open to refactoring the structure in any way needed to make this work visually.
Thanks!
You can apply width calculations for each level. This gets your styles out of your markup, too.
body {
font-size: 16px;
font-family: monospace;
}
.tree {
min-width: 200px;
width: 200px;
height: 150px;
margin: 0;
padding: 20px 0;
overflow-x: scroll;
white-space: nowrap;
background-color: #ebedef;
}
.tree-node {
width: calc(100% + 15px);
height: 18px;
padding: 6px 0;
cursor: pointer;
background: pink;
}
.tree-node.level-1 {
padding-left: 15px;
width: calc(100% + 75px);
}
.tree-node.level-2 {
padding-left: 30px;
width: calc(100% + 60px);
}
.tree-node.level-3 {
padding-left: 45px;
width: calc(100% + 45px);
}
.tree-node.level-4 {
padding-left: 60px;
width: calc(100% + 30px);
}
.tree-node:hover {
background-color: #dbdde0;
}
.tree-node span {
line-height: 18px;
}
.tree-node svg {
margin-right: 7px;
}
<body>
<ul class="tree">
<li tabindex="0" class="tree-node level-1 tree-node--directory">
<span>/</span>
</li>
<li tabindex="0" class="tree-node level-2 tree-node--directory">
<span>dir1</span>
</li>
<li tabindex="0" class="tree-node level-3 tree-node--directory">
<span>dir2</span>
</li>
<li tabindex="0" class="tree-node level-4 tree-node--file">
<span>transformations.js</span>
</li>
</ul>
</body>
Simply add display:grid to tree element. You may need to also adjust the alignment:
body {
font-size: 16px;
font-family: monospace;
}
.tree {
box-sizing: border-box;
min-width: 200px;
width: 200px;
height: 400px;
margin: 0;
padding: 20px 0;
overflow-x: scroll;
white-space: nowrap;
background-color: #ebedef;
/* added */
display:grid;
align-content:flex-start;
/**/
}
.tree-node {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: stretch;
justify-content: flex-start;
height: 18px;
padding: 6px 0;
cursor: pointer;
}
.tree-node:hover {
background-color: #dbdde0;
}
.tree-node span {
line-height: 18px;
}
.tree-node svg {
margin-right: 7px;
}
<body>
<ul class="tree">
<li style="padding-left: 15px;" tabindex="0" class="tree-node tree-node--directory">
<span>/</span>
</li>
<li style="padding-left: 30px;" tabindex="0" class="tree-node tree-node--directory">
<span>dir1</span>
</li>
<li style="padding-left: 45px;" tabindex="0" class="tree-node tree-node--directory">
<span>dir2</span>
</li>
<li style="padding-left: 60px;" tabindex="0" class="tree-node tree-node--file">
<span>transformations.js</span>
</li>
<li style="padding-left: 45px;" tabindex="0" class="tree-node tree-node--file">
<span>foo.js</span>
</li>
<li style="padding-left: 30px;" tabindex="0" class="tree-node tree-node--file">
<span>package.json</span>
</li>
</ul>
</body>
I would suggest to use display: block instead of display: flex and to add the padding to the spans. The problem is that the .tree doesn't cover the whole container but without the scroll. I couldn't find a solution without Javascript.
const container = document.querySelector('.container');
const tree = document.querySelector('.tree');
tree.style.width = container.scrollWidth + 'px';
body {
font-size: 16px;
font-family: monospace;
}
.container{
min-width: 200px;
width: 200px;
overflow-x: scroll;
background-color: #ebedef;
}
.tree {
box-sizing: border-box;
list-style-type: none;
height: 400px;
margin: 0;
padding: 20px 0;
display: block;
}
.tree-node {
display: block;
height: 18px;
padding: 6px 0;
cursor: pointer;
}
.tree-node:hover {
background-color: #dbdde0;
}
span {
line-height: 18px;
display:block;
}
svg {
margin-right: 7px;
}
<div class="container">
<ul class="tree">
<li tabindex="0" class="tree-node tree-node--directory">
<span style="padding-left: 15px;">/</span>
</li>
<li tabindex="0" class="tree-node tree-node--directory">
<span >dir1</span>
</li>
<li tabindex="0" class="tree-node tree-node--directory">
<span style="padding-left: 45px;">dir2</span>
</li>
<li tabindex="0" class="tree-node tree-node--file">
<span style="padding-left: 60px;">transformations.js</span>
</li>
<li tabindex="0" class="tree-node tree-node--file">
<span style="padding-left: 45px;">foo.js</span>
</li>
<li tabindex="0" class="tree-node tree-node--file">
<span style="padding-left: 30px;">package.json</span>
</li>
</ul>
</div>
You just need to provide width: 100%; to the li element and you are good to go. It will work exactly as you want it to. You can either use nth-child selector or you can just do it for all of the li elements so that each element has the same behaviour.
If you want to do it using javascript then it would be a little easier. What you need to do is
// Get the scroll width of your ul
const scrollWidth = document.querySelector("ul.tree").scrollWidth;
// Now select the li element or all of them and put them in a loop
// for now I'm doing it for the first one just for simplicity
// but the same goes for all of the others
const element = document.querySelector("li");
element.style.width = scrollWidth + "px";
// You can console log scroll width to see what it outputs
Another way using css
You have to do it separately for different elements. For example, the elements with 30px padding can have one rule but the ones with 60px padding on left will have slight change in it
/* select the particular li element */
/* in this case assume I have given p-30 class to all elements with 30px of padding */
.p-30 {
width: calc(100% + 30px);
}
The problem is on the "container main" div, which has the overflow-y. When the <form> height gets increased and the overflow starts to work on the "container div", it's not possible to see the whole form and the top part gets hidden
I don't think it's normal behavior, I've been some hours at this problem and just can't solve it the way I wanted (by leaving the form centered with "container main" flexbox)
.form-background {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -999;
backdrop-filter: brightness(125%) hue-rotate(180deg) blur(10px);
background-color: rgba(0, 0, 0, .5)
}
body {
background-image: url(https://images.pexels.com/photos/1624600/pexels-photo-1624600.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260)
}
section {
height: 100vh;
display: flex;
flex-direction: column;
overflow: auto!important
}
.main.container {
flex-grow: 3;
height: auto;
padding: 0 50px;
overflow-y: scroll;
margin: 50px auto 50px auto;
display: flex;
align-items: center;
}
form {
width: 100%;
}
.edit {
width: 50%;
display: inline-block
}
.edit .input-file {
cursor: pointer
}
.edit.middle,
.edit.middle input {
width: 100%
}
.edit.custom-input {
width: 100%;
display: flex
}
.edit.right {
padding-left: 5px
}
.edit.left {
padding-right: 5px
}
.clickin {
margin: 15px 0
}
form>.box:nth-child(n+2) {
margin-top: 70px
}
.current-templates,
.mob {
display: none;
margin-top: 20px;
}
.current-templates .file {
padding: 10px;
font-size: 1.2rem
}
.current-templates .file:not(:first-child) {
margin-top: 20px
}
.current-templates .file,
.current-templates .options {
display: flex;
align-items: center
}
.current-templates .options {
width: 100%;
justify-content: space-around
}
.current-templates .file span {
white-space: nowrap
}
.current-templates .options {
margin-left: 30px;
list-style: none;
overflow: auto
}
.current-templates .options li {
padding: 4px 25px;
cursor: pointer;
white-space: nowrap;
text-align: center;
transition: background-color .2s var(--cubic-bezier)
}
.current-templates .options li:hover {
background-color: var(--hover-color)
}
.current-templates .options .opt[selected=true] {
background-color: rgba(18, 238, 102, .466)
}
.btn-wrapper {
width: 100%;
display: flex;
justify-content: center;
align-items: center
}
.btn-wrapper button {
padding: 10px;
font-size: 1.1rem;
cursor: pointer;
outline: 0;
border: solid #000 1px;
width: 200px;
margin-top: 30px
}
.btn-anim {
transition: background-color .2s var(--cubic-bezier), color .2s var(--cubic-bezier);
background-color: var(--input-color)
}
.btn-anim:hover {
background-color: var(--hover-color) !important;
color: #fff
}
.btn-anim-blocked:hover {
background-color: rgba(255, 110, 110, .363)!important;
color: #fff
}
.fas.fa-question {
font-size: .8rem;
margin-left: 15px;
cursor: pointer;
padding: 5px;
position: relative
}
.img {
position: absolute;
left: 100%;
top: 0;
visibility: hidden;
opacity: 0;
transform: translate(-50%, -150%);
transition: visibility .2s var(--cubic-bezier), opacity .2s var(--cubic-bezier), transform .2s var(--cubic-bezier)
}
button.refresh-options i {
background-color: transparent;
border: none;
border-radius: 100%;
padding: 5px 8px;
transition: transform 1s var(--cubic-bezier)
}
button.refresh-options {
background-color: transparent;
border: none;
padding: 8px;
font-size: 1rem;
cursor: pointer;
outline: 0;
display: none
}
.edit .input-file,
.edit input {
background-color: var(--input-color)
}
button.refresh-options:hover i {
transform: rotateZ(360deg)
}
.check-box {
margin: 15px 0 25px 1px;
display: flex;
align-items: center
}
.check-box .square {
position: relative;
width: 20px;
height: 20px;
background-color: transparent;
border: solid #fff 1px;
cursor: pointer
}
.check-box span {
margin-left: 20px
}
header {
position: fixed;
width: 100%;
background-color: transparent;
}
.container.nav-content {
padding: 0;
overflow: auto;
}
.container.nav-content {
grid-template-columns: auto 1fr;
justify-content: space-between;
}
ul.nav-opts {
justify-content: flex-end;
}
.fake-nav {
height: 74px;
margin-bottom: 30px;
}
<section>
<div class="fake-nav"></div>
<header>
<nav>
<div class="container nav-content">
<div class="brand">
<img src="" alt="clickin logo">
</div>
<ul class="nav-opts">
<li>Home</li>
<li>Posts</li>
<li>Imagens</li>
</ul>
</div>
</nav>
</header>
<div class="container main">
<div class="form-background"></div>
<form>
<div class="edit-wrapper box">
<div class="edit left"> <label>Id do board <i class="fas fa-question"> <img class="img" src="" alt="Board Id?"> </i></label> <input name="board_id" type="number" required> </div>
<div class="edit right"> <label>Nome do Grupo<i class="fas fa-question"> <img class="img" src="" alt="Nome do Grupo?"> </i></label> <input name="group_name" type="text" required> </div>
</div>
<div class="edit middle box"> <label>Diretório da pasta para construção da estrutura<i class="fas fa-question"> <img class="img" src="" alt="Diretório desejado?"> </i></label> <input name="desired_path" type="text" required> </div>
<div class="edit-wrapper box">
<div class="edit left"> <label>Diretório dos Templates<i class="fas fa-question"> <img class="img" src="" alt="Diretório dos templates?"> </i></label> <input name="templates_path" type="text" required> </div>
<div class="edit right"> <label>Selecione os templates<i class="fas fa-question"> <img class="img" src=""> </i></label> <label class="input-file btn-anim" for="templates">Templates</label> <input name="templates" disabled id="templates" type="file" accept=".psd" multiple
required> </div>
</div>
<div class="edit-wrapper">
<div class="check-box" data-selected="false">
<div class="square"></div>
<span>Templates estruturados em ordem</span>
</div>
</div>
<div class="edit-wrapper mob">
<button type="button" class="refresh-options btn-anim"> Recarregar temas por possíveis mudanças <i class="fas fa-redo-alt"></i> </button>
<center> <img width="100px" class="loader" src="" alt="loading"> </center>
</div>
<div class="current-templates" style="display: block;">
<div class="file" selected_topics="">
<span class="template-name">Template 1</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 2</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 3</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
</div>
<div class="btn-wrapper"> <button class="btn-anim" type="submit">Gerar!</button> </div>
</form>
</div>
<footer>Copyright 2021 © João Webber</footer>
</section>
I think the offending part of your CSS code is this one:
.main.container {
flex-grow: 3;
height: auto;
padding: 0 50px;
overflow-y: scroll;
margin: 50px auto 50px auto;
display: flex;
align-items: center;
}
The margin: 50px auto 50px auto; forces your main.container to get squeezed in between your header and your footer, but the form is contains is not following his parent height.
Either:
you remove the overflow-y: scroll from .main.container to allow the <form> to increase the height of his parent, but no more scroll bar inside .main.container.
or you set <form> height: 100% to force him to take its parent height, which will still cause the scroll bar to appear in .main.container (because the form content can't be squeezed) but the top of your <form> will be aligned to the top of .main.container.
It's about 'display: flex;' a flexbox is not just one single property, it's a whole module. If your interested in reading a article about flexbox: guide to use flex-box.
When you delete the display: flex; in your main container it will solve your problem.
.form-background {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -999;
backdrop-filter: brightness(125%) hue-rotate(180deg) blur(10px);
background-color: rgba(0, 0, 0, .5)
}
/*
body {
background-image: url(https://images.pexels.com/photos/1624600/pexels-photo-1624600.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260)
}*/
section {
height: 100vh;
display: flex;
flex-direction: column;
overflow: auto!important
}
.container.main {
flex-grow: 3;
height: auto;
padding: 0 50px;
overflow-y: scroll;
margin: 50px auto 50px auto;
}
form {
width: 100%;
}
.edit {
width: 50%;
display: inline-block
}
.edit .input-file {
cursor: pointer
}
.edit.middle,
.edit.middle input {
width: 100%
}
.edit.custom-input {
width: 100%;
display: flex
}
.edit.right {
padding-left: 5px
}
.edit.left {
padding-right: 5px
}
.clickin {
margin: 15px 0
}
form>.box:nth-child(n+2) {
margin-top: 70px
}
.current-templates,
.mob {
display: none;
margin-top: 20px;
}
.current-templates .file {
padding: 10px;
font-size: 1.2rem
}
.current-templates .file:not(:first-child) {
margin-top: 20px
}
.current-templates .file,
.current-templates .options {
display: flex;
align-items: center
}
.current-templates .options {
width: 100%;
justify-content: space-around
}
.current-templates .file span {
white-space: nowrap
}
.current-templates .options {
margin-left: 30px;
list-style: none;
overflow: auto
}
.current-templates .options li {
padding: 4px 25px;
cursor: pointer;
white-space: nowrap;
text-align: center;
transition: background-color .2s var(--cubic-bezier)
}
.current-templates .options li:hover {
background-color: var(--hover-color)
}
.current-templates .options .opt[selected=true] {
background-color: rgba(18, 238, 102, .466)
}
.btn-wrapper {
width: 100%;
display: flex;
justify-content: center;
align-items: center
}
.btn-wrapper button {
padding: 10px;
font-size: 1.1rem;
cursor: pointer;
outline: 0;
border: solid #000 1px;
width: 200px;
margin-top: 30px
}
.btn-anim {
transition: background-color .2s var(--cubic-bezier), color .2s var(--cubic-bezier);
background-color: var(--input-color)
}
.btn-anim:hover {
background-color: var(--hover-color) !important;
color: #fff
}
.btn-anim-blocked:hover {
background-color: rgba(255, 110, 110, .363)!important;
color: #fff
}
.fas.fa-question {
font-size: .8rem;
margin-left: 15px;
cursor: pointer;
padding: 5px;
position: relative
}
.img {
position: absolute;
left: 100%;
top: 0;
visibility: hidden;
opacity: 0;
transform: translate(-50%, -150%);
transition: visibility .2s var(--cubic-bezier), opacity .2s var(--cubic-bezier), transform .2s var(--cubic-bezier)
}
button.refresh-options i {
background-color: transparent;
border: none;
border-radius: 100%;
padding: 5px 8px;
transition: transform 1s var(--cubic-bezier)
}
button.refresh-options {
background-color: transparent;
border: none;
padding: 8px;
font-size: 1rem;
cursor: pointer;
outline: 0;
display: none
}
.edit .input-file,
.edit input {
background-color: var(--input-color)
}
button.refresh-options:hover i {
transform: rotateZ(360deg)
}
.check-box {
margin: 15px 0 25px 1px;
display: flex;
align-items: center
}
.check-box .square {
position: relative;
width: 20px;
height: 20px;
background-color: transparent;
border: solid #fff 1px;
cursor: pointer
}
.check-box span {
margin-left: 20px
}
header {
position: fixed;
width: 100%;
background-color: transparent;
}
.container.nav-content {
padding: 0;
overflow: auto;
}
.container.nav-content {
grid-template-columns: auto 1fr;
justify-content: space-between;
}
ul.nav-opts {
justify-content: flex-end;
}
.fake-nav {
height: 74px;
margin-bottom: 30px;
}
<section>
<div class="fake-nav"></div>
<header>
<nav>
<div class="container nav-content">
<div class="brand">
<img src="" alt="clickin logo">
</div>
<ul class="nav-opts">
<li>Home</li>
<li>Posts</li>
<li>Imagens</li>
</ul>
</div>
</nav>
</header>
<div class="container main">
<div class="form-background"></div>
<form>
<div class="edit-wrapper box">
<div class="edit left"> <label>Id do board <i class="fas fa-question"> <img class="img" src="" alt="Board Id?"> </i></label> <input name="board_id" type="number" required> </div>
<div class="edit right"> <label>Nome do Grupo<i class="fas fa-question"> <img class="img" src="" alt="Nome do Grupo?"> </i></label> <input name="group_name" type="text" required> </div>
</div>
<div class="edit middle box"> <label>Diretório da pasta para construção da estrutura<i class="fas fa-question"> <img class="img" src="" alt="Diretório desejado?"> </i></label> <input name="desired_path" type="text" required> </div>
<div class="edit-wrapper box">
<div class="edit left"> <label>Diretório dos Templates<i class="fas fa-question"> <img class="img" src="" alt="Diretório dos templates?"> </i></label> <input name="templates_path" type="text" required> </div>
<div class="edit right"> <label>Selecione os templates<i class="fas fa-question"> <img class="img" src=""> </i></label> <label class="input-file btn-anim" for="templates">Templates</label> <input name="templates" disabled id="templates" type="file" accept=".psd" multiple
required> </div>
</div>
<div class="edit-wrapper">
<div class="check-box" data-selected="false">
<div class="square"></div>
<span>Templates estruturados em ordem</span>
</div>
</div>
<div class="edit-wrapper mob">
<button type="button" class="refresh-options btn-anim"> Recarregar temas por possíveis mudanças <i class="fas fa-redo-alt"></i> </button>
<center> <img width="100px" class="loader" src="" alt="loading"> </center>
</div>
<div class="current-templates" style="display: block;">
<div class="file" selected_topics="">
<span class="template-name">Template 1</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 2</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 3</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
</div>
<div class="btn-wrapper"> <button class="btn-anim" type="submit">Gerar!</button> </div>
</form>
</div>
<footer>Copyright 2021 © João Webber</footer>
</section>
Why does the ul element get the full width of the wrapper element when the container div is its parent? And how can I change this?
Structure of the HTML:
Wrapper
| container
| label
| input
| ul
| botton
HTML & CSS:
.wrapper{
margin: 20px auto;
}
.container {
position: relative;
display: flex;
flex-direction: column;
height: 200px;
width: 80%;
margin: auto;
}
.country-input {
height: 30px;
margin-bottom: 50px;
}
ul {
height: 200px;
width: 100%;
overflow: hidden;
overflow-y: scroll;
position: absolute;
background-color: #F2F2F2;
top: 20px;
left: 0px;
}
<div class="wrapper">
<div class="container">
<label for="country">State</label>
<input class="input country-input" id="country" type="text" />
<ul id='country-list'>
<li id="US">United States</li>
<li id="AF">Afghanistan</li>
<li id="AX">Åland Islands</li>
<li id="AL">Albania</li>
</ul>
<button>explore</button>
</div>
</div>
Here is a link to the full code
This is how it looks:
here
On the left you can see the negative position the element gets:
here
Its just because your <ul> tag is using padding. Look at snippet and tell me is that what you're looking for?
.wrapper{
margin: 20px auto;
}
.container {
position: relative;
display: flex;
flex-direction: column;
height: 200px;
width: 80%;
margin: auto
}
.country-input {
height: 30px;
margin-bottom: 50px;
}
ul {
height: 200px;
width: 100%;
overflow: hidden;
overflow-y: scroll;
position: absolute;
background-color: #F2F2F2;
top: 20px;
padding: 0;
}
li {
padding-left: 40px;
}
<div class="wrapper">
<div class="container">
<label for="country">State</label>
<input class="input country-input" id="country" type="text" />
<ul id='country-list'>
<li id="US">United States</li>
<li id="AF">Afghanistan</li>
<li id="AX">Åland Islands</li>
<li id="AL">Albania</li>
</ul>
<button>explore</button>
</div>
</div>
You may also consider using select + option tags instead of unordered list.
Example:
<select id='country-list'>
<option id="US">United States</li>
<option id="AF">Afghanistan</li>
<option id="AX">Åland Islands</li>
<option id="AL">Albania</li>
</select>
set in the ul tag - width: unset, left: 0 and right: 0
.wrapper{
margin: 20px auto;
}
.container {
position: relative;
display: flex;
flex-direction: column;
height: 200px;
width: 80%;
margin: auto
}
.country-input {
height: 30px;
margin-bottom: 50px;
}
ul {
height: 200px;
width: unset;
overflow: hidden;
overflow-y: scroll;
position: absolute;
background-color: #F2F2F2;
top: 20px;
left: 0;
right: 0;
}
<div class="wrapper">
<div class="container">
<label for="country">State</label>
<input class="input country-input" id="country" type="text" />
<ul id='country-list'>
<li id="US">United States</li>
<li id="AF">Afghanistan</li>
<li id="AX">Åland Islands</li>
<li id="AL">Albania</li>
</ul>
<button>explore</button>
</div>
</div>
please set the style of ul, padding:0px;
So I'm using hero image for my website which is 100 vh high. Now the image is positioned absolutely, so I could position other elements like logo, nav and text on the image relatively to it. After this section, I want to start new section with new image and other text, but once I start new row, column and try to put new image with h1 text, it's hiding behind earlier image. What I mean is that I want a new section with new image and <h1> text appear under the hero image and not overlap it or hide under it as it is now hiding. It's not floated or anything, my floats are cleared, so I don't get it why is this hapenning.
Here is some codepen so you would understand what is hapenning.
<div class="container-fluid clearfix">
<div class="row">
<div class="col-lg-12">
<div class="hero_img">
<img class="logo" src="assets/logo.png"></img>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".collapse">
☰
</button>
<div class="collapse">
<div class="col-xs-12">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lorem</a>
</li>
</ul>
</div>
</div>
<div class="black_box clearfix"><h1>Kolding Bike Marathon</h1></div>
<div class="black_box_sub clearfix"><p>Bring activity to your life again</p></div>
<button type="button" class="btn btn-outline-secondary">Register now</button>
<button type="button" class="btn btn-success">Learn more</button>
</div>
</div>
</div>
</div>
</div>
<div class="section_one">
<h1>heyyyyy</h1>
</div>
.hero_img {
background-image: url("assets/hero.jpg");
width: auto;
height: 100vh;
background-size: cover;
position: absolute;
top: 0;
left: 0;
z-index: 999;
overflow: hidden;
clear: both;
}
.hero_img {
width: 100%;
height: 100vh;
position: absolute;
top: 0;
}
.logo {
position: relative;
left: 20px;
top: 20px;
z-index: 1002;
width: 5%;
min-width: 50px;
}
.nav {
position: relative;
top: 0;
z-index: 1000;
margin-top: 20px;
/*margin-right: 15px;*/
padding: 20px;
/*float: right;*/
width: auto;
flex-direction: column;
background: #555;
/*width: 100%;*/
filter: opacity(0.93);
}
a {
text-decoration: none;
color: white;
display: block;
border-bottom: 1px solid #444;
}
a:hover {
color: #999;
}
.nav-item {
display: block;
}
.navbar-toggler {
/*float: right;*/
display: flex;
justify-content: right;
position: relative;
z-index: 1000;
margin-top: 15px;
margin-right: 15px;
color: white;
float: right;
}
.black_box {
position: relative;
width: 45%;
min-width: 400px;
text-align: center;
z-index: 1000;
background: black;
margin-top: 10%;
padding: 10px 30px;
clear: both;
}
.black_box h1 {
color: white;
/*font-family: 'PT Sans', sans-serif;*/
font-family: 'Montserrat', sans-serif;
font-weight: 600;
letter-spacing: 1.5px;
}
.black_box_sub {
position: relative;
width: 30%;
min-width: 310px;
text-align: center;
z-index: 1001;
background: black;
margin-top: 2%;
clear: both;
margin-left: 90px;
}
.black_box_sub p {
color: white;
padding: 5px 25px;
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
padding-top: 10px;
padding-bottom: 0px;
}
Codepen: http://codepen.io/Limpuls/pen/NpbwYp
There are multiple items to clean up in the code, but to keep the images from overlapping you can remove both entries of position: absolute; from the .hero_img class.
After that, remove the padding left and right from all of the media queries of container-fluid. This may affect and other padding that was needed in that container but would be a quick path to do what you are asking.