Encountering overlap issues when applying labels to my flexbox using the Spectre framework in CSS

I need help creating a "hat" with two textarea columns using the spectre.css framework. My goal is to have these columns resize based on the screen size, stacking on top of each other when the screen size is below 600px. I can achieve this without any issues as long as the textarea doesn't have an associated label. But when there's a label, it causes the textarea to overlap the current column space at the bottom. It seems like the label isn't being factored in when calculating the column size and I'm not sure why. Can you help me fix this issue?

*, ::before, ::after {
  box-sizing: border-box;
}

.container {
  margin-left: auto;
  margin-right: auto;
  padding-left: .4rem;
  padding-right: .4rem;
  width: 100%;
}

.columns {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-left: -.4rem;
  margin-right: -.4rem;
}

.column {
  -ms-flex: 1;
  flex: 1;
  max-width: 100%;
  padding: .25rem;
}

.col-12,
.col-11,
.col-10,
.col-9,
.col-6 {
   -ms-flex: none;
    flex: none;
}

.col-12 {
  width: 100%;
}

.col-10 {
  width: 83.33333333%;
}

.col-9 {
  width: 75%;
}

.col-6 {
  width: 50%;
}

@media (max-width: 600px) {
  #hattop {
    height: 35vh;
  }
  
  .column.col-sm-12,
  .column.col-sm-11 {
   -ms-flex: none;
    flex: none;
  }
  
 .col-sm-12 {
    width: 100%;
  }
  
  .col-sm-11 {
    width: 91.66666667%;
  }
}

.col-mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.col-ml-auto {
  margin-left: auto;
}

.col-mr-auto {
  margin-right: auto;
}

.form-label {
  color: #fff;
}

.form-input {
  appearance: none;
  background: #fff;
  border: .05rem solid #5755d9;
  border-radius: 10px;
  color: #3b4351;
  max-width: 100%;
  padding: .25rem .4rem;
  position: relative;
  transition: background .2s, border .2s, box-shadow .2s, color .2s;
  width: 100%;
  word-wrap: anywhere;
}

textarea {
  overflow: auto;
  resize: none;
}

textarea.form-input {
  height: 100%;
  width: 100%;
}

#hattop {
  background-color: rgb(31, 26, 44);
  padding: 1rem .5rem;
  height: 50vh;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

@media (max-width: 600px) {
  #hattop {
    height: 35vh;
  }
}
<div class="container">
    <div class="columns col-sm-11 col-10 col-mx-auto">
        <div id="hattop" class="columns col-9 col-mx-auto">
            <div class="column col-sm-12 col-6 col-ml-auto">
                <label for="nams" class="form-label">Enter names separated by line</label>
                <textarea class="form-input" id="names" placeholder="Names"></textarea>
            </div>
            <div class="column col-sm-12 col-6 col-mr-auto">
                <label for="tasks" class="form-label">Enter tasks separated by line</label>
                <textarea class="form-input" id="tasks" placeholder="Tasks"></textarea>
            </div>
        </div>
    </div>
</div>

Answer №1

Resolved the issue by adjusting the #hattop height attribute in conjunction with the textarea height attribute set to 100%. This caused the textarea to always match the full height of the hattop, without considering the label.

Removed the #hattop height attribute and updated the textarea height attribute to be 50vh for screens larger than 600px, and 20vh for smaller screens. The size remains consistent but is now responsive!

*, ::before, ::after {
  box-sizing: border-box;
}

.container {
  margin-left: auto;
  margin-right: auto;
  padding-left: .4rem;
  padding-right: .4rem;
  width: 100%;
}

.columns {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-left: -.4rem;
  margin-right: -.4rem;
}

.column {
  -ms-flex: 1;
  flex: 1;
  max-width: 100%;
  padding: .25rem;
}

.col-12,
.col-11,
.col-10,
.col-9,
.col-6 {
   -ms-flex: none;
    flex: none;
}

.col-12 {
  width: 100%;
}

.col-10 {
  width: 83.33333333%;
}

.col-9 {
  width: 75%;
}

.col-6 {
  width: 50%;
}

@media (max-width: 600px) {

  .column.col-sm-12,
  .column.col-sm-11 {
   -ms-flex: none;
    flex: none;
  }
  
 .col-sm-12 {
    width: 100%;
  }
  
  .col-sm-11 {
    width: 91.66666667%;
  }
}

.col-mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.col-ml-auto {
  margin-left: auto;
}

.col-mr-auto {
  margin-right: auto;
}

.form-label {
  color: #fff;
}

.form-input {
  appearance: none;
  background: #fff;
  border: .05rem solid #5755d9;
  border-radius: 10px;
  color: #3b4351;
  max-width: 100%;
  padding: .25rem .4rem;
  position: relative;
  transition: background .2s, border .2s, box-shadow .2s, color .2s;
  width: 100%;
  word-wrap: anywhere;
}

textarea {
  overflow: auto;
  resize: none;
}

textarea.form-input {
  height: 40vh;
  width: 100%;
}

@media (max-width: 600px) {
    textarea.form-input {
    height: 20vh;
  }
}


#hattop {
  background-color: rgb(31, 26, 44);
  padding: 1rem .5rem;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}
<div class="container">
    <div class="columns col-sm-11 col-10 col-mx-auto">
        <div id="hattop" class="columns col-9 col-mx-auto">
            <div class="column col-sm-12 col-6 col-ml-auto">
                <label for="nams" class="form-label">Enter names separated by line</label>
                <textarea class="form-input" id="names" placeholder="Names"></textarea>
            </div>
            <div class="column col-sm-12 col-6 col-mr-auto">
                <label for="tasks" class="form-label">Enter tasks separated by line</label>
                <textarea class="form-input" id="tasks" placeholder="Tasks"></textarea>
            </div>
        </div>
    </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Variety of color palettes within a single style sheet

My theme features various styles, including different color schemes. Currently, I load the default CSS first and then an additional stylesheet with specific colors based on the chosen color scheme. However, this process is causing a delay in my site' ...

embedding fashion within offspring component in vue

Looking to apply inline styles to a child component? I am trying to pass properties like height: 200px and overflow-y: scroll. I attempted passing it this way: <Childcomponent style="height: 200px; overflow-y: scroll;" /> but had no luck. ...

Navigating through nested arrays in Laravel Blade templates

I have an array that is displaying the code below after being dumped. array:1[ "123"=>array:3[ "test1" => 12345 "test2" => "test" "test3" => 123 ] ] When trying to display each element in an HTML table, the val ...

Issue with linear gradient not functioning in :before pseudo element

Does anyone know how to create a triangle cut effect on a div without the background being rendered as a rectangle? body { background: #333; } .parent { height: 200px; background: yellow; position: relative; overflow: hidden; display: block ...

Display or conceal the location where the click event occurs within a single div

progress $(".button-toggle").click(function(e){ $(this).parents.find('#second').toggle(); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="first"> <a href="#" class= ...

Tips for retrieving and displaying values from a form using only PHP

I have a simple request: I want to input a name, click the submit button, and then display the name below the form. Seems easy right? <?php echo $_POST['one']; ?> <!DocType HTML> <html> <body> <p> ...

"Automate the process of manual content duplication with JavaScript's for each replacement

Seeking a solution to automate the selection process without writing individual JS scripts for every input. For instance, having 10 double inputs (total of 20 inputs) and utilizing the each() function or other methods by only declaring selectors. Find th ...

Creating a floating border effect.Would you like to know how

Currently working on a new component, I'm looking to create a unique border for certain cards. However, I'm struggling to find the perfect solution. Check out the specific border style needed in the image provided below. https://i.sstatic.net/4vA ...

The presentation of an HTML table varies between Gmail and web browsers

<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" height="131" border="0" cellspacing="0" cellpadding="0"> <tr> <td wid ...

What is the best way to make a child div's height match its parent's height?

I am facing an issue with aligning 2 divs on the same line, separated by a vertical line while ensuring that the line always has the height of the parent div. Despite trying various solutions suggested online, none seem to work for me. I cannot use positi ...

Locate the coordinates on an HTML5 canvas that correspond to a specified color

Is there a more efficient method to identify the coordinates of pixels with a particular color without looping through every pixel in the image? ...

The program waited for 60 seconds for the element to become clickable in the Selenium webdriver, but it timed out

I am currently working on Selenium web driver and trying to locate the element with the ID visualizationId, but I keep encountering an error. Below is the code snippet where the error occurs: Actions actions1 = new Actions(driver); WebElement dBox1= ((new ...

Compatible with pure vanilla JavaScript, but not jQuery

I am currently facing an issue with attaching VKI (Virtual Keyboard Interface) to an element that is dynamically added to the DOM using JavaScript. The scenario involves a table with initially only one row, along with "Add Row" and "Delete Row" functionali ...

Troubleshooting Issues with Bootstrap Carousel Functionality

I'm facing some difficulties with the Bootstrap carousel on my website. I have followed all the instructions carefully and researched for solutions, but unfortunately, my carousel is not functioning properly. It seems like everything is set up correct ...

Tips for customizing Material-UI Switch button appearance

Is there a way to remove the box-shadow on the thumb of the Switch button when it's disabled? I've tried various methods like adding the box-shadow in the switchBase and removing it from the thumb, but it affects the parent element as well. Anoth ...

The like button animation works perfectly for individual posts, but for multiple posts, only the like button on the first post

Having an issue with the like button code on a single news feed. The button works for the first post, but when clicking on other posts, it only affects the first post button. I am using post UI and looping the UI based on the total post count without Javas ...

Issues encountered when dealing with floating elements and margins

Having some difficulties with aligning elements on my website. As someone who is not highly skilled in coding, I am struggling to define the width and float properties for certain classes. Despite my attempts, it seems that the elements are not positioning ...

What is the best way to update the src of an input using an onclick event?

When I click the input, my background changes color as expected. However, the src of the input only changes on the second click. How can I make it change the source on the first click? Also, how can I change the src back to the original with a second cli ...

Tips for using unique fonts in email text display

As I was editing a Mailer template in core php, I found myself wanting to set a custom font for the text displayed in the mail template similar to how we do it for websites using CSS and imported fonts. Below is the code snippet that I have been using: & ...

Display an image tag using the site_url() function within PHP brackets

I have a loop in my view that is fetching all the data from the database: <?php foreach($content as $contentRow): ?> <?php echo $contentRow->value; ?> <?php endforeach; ?> This loop works well for HTML strings ...