How can I position a button below the text area but outside of its boundaries?

Greetings! Here's an image of the current state I am in: https://i.sstatic.net/Ceemp.jpg

However, my desired outcome should look like this: https://i.sstatic.net/0IN5w.jpg

In my text area, consisting of 5 rows, I would like the button to be positioned towards the bottom of the text area.

This is the code I have used:

<div class="row">
<p class="col-sm-6 col-md-10 ">
<b >Mail</b> <br />                                                         
<textarea class="form-control" rows="5" id="Email"></textarea>
</p>
<p class="col-sm-6 col-md-2">
<br />
<a id="btnSave" onclick="SaveValue()" class="btn btn-success btn-flat btn-xs-block"><span style="color: #fff;" class="glyphicon glyphicon-save"></span>Save</a></p> </div> 

I have come across some suggestions advising me to add a Bootstrap 4.0 link. However, it did not work as expected and only altered my display slightly. Here's an image for reference: https://i.sstatic.net/0x3nY.jpg

Answer №1

Here is an unconventional response to the question, but it has proven effective in my case

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row" style="position:relative">
<div class="col-sm-6 col-md-10 ">
<b >Mail</b> <br />                                                         
<textarea class="form-control" rows="5" id="Email"></textarea>
</div>
<div class="col-sm-6 col-md-2" style="position:relative">
<br />
<a id="btnSave"  onclick="SaveValue()" class="btn btn-success btn-flat btn-xs-block" style="position:absolute;bottom:0"><span style="color: #fff;" class="glyphicon glyphicon-save"></span>Save</a></div> </div>

Answer №2

Implement the inline form feature of bootstrap and adjust the button position to be absolute with a bottom value of 0 within a parent div set to relative positioning. This will ensure that the button is located at the bottom area in relation to its parent element.

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

<div class="container" style="position:relative">
  <form class="form-inline" action="/action_page.php">
  <div class="form-group col-xs-10">
   <textarea class="form-control" rows="5" id="comment"></textarea>
  </div>

  <button type="submit" style="position:absolute;bottom:15px;" class="btn btn-default">Submit</button>

</form> 
</div>

Answer №3

It is recommended to utilize a table for this purpose.

<div class="row">
<table style="width: 100%">
    <tr>
        <td class="col-md-6 col-md-offset-1">
                <b >Mail</b>
        </td>
    </tr>
 <tr>
     <td>
            <textarea class="form-control" rows="5" id="Email"></textarea>
     </td>
     <td style="vertical-align: bottom">
            <a id="btnSave"  onclick="SaveValue()" class="btn btn-success btn-flat btn-xs-block"><span style="color: #fff;" class="glyphicon glyphicon-save"></span>Save</a>
     </td>
 </tr>       
</table>
 </div>

Answer №4

When utilizing Bootstrap 4, you have the option to include d-flex align-items-end in your button wrapper based on the new Bootstrap 4 flexbox utilities...

Furthermore, it is recommended to convert your paragraph columns to div elements since they are not paragraphs. You can refer to: https://www.w3schools.com/html/html_paragraphs.asp

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="container">
  <div class="row">
    <div class="col-sm-6 col-md-10 ">
      <b >Mail</b> <br />                                                         
      <textarea class="form-control" rows="5" id="Email"></textarea>
    </div>
    <div class="col-sm-6 col-md-2 d-flex align-items-end">
      <a id="btnSave"  onclick="SaveValue()" class="btn btn-success btn-flat btn-xs-block">
        <span style="color: #fff;" class="glyphicon glyphicon-save"></span>
        Save
      </a>
    </div>
   </div>
 </div>

If you prefer not to use Bootstrap, you can assign a class to your wrapper and apply the following CSS:

.form-wrapper > div {
    display: inline-block;
    vertical-align: bottom;
}

.form-wrapper > div {
    display: inline-block;
    vertical-align: bottom;
}
<div class="container">
  <div class="row form-wrapper">
    <div class="col-sm-6 col-md-10 ">
      <b >Mail</b> <br />                                                         
      <textarea class="form-control" rows="5" id="Email"></textarea>
    </div>
    <div class="col-sm-6 col-md-2">
      <a id="btnSave"  onclick="SaveValue()" class="btn btn-success btn-flat btn-xs-block">
        <span style="color: #fff;" class="glyphicon glyphicon-save"></span>
        Save
      </a>
    </div>
   </div>
 </div>

Answer №5

Thanks to everyone for your suggestions. I tried everything mentioned above, but nothing seemed to work flawlessly. Eventually, I decided to simply add <br /> into the code and that miraculously fixed my issue. Here is the modified code snippet:

<p class="col-sm-6 col-md-6 ">
<b >Mail </b> <br />
<textarea class="form-control" rows="5" id="Email"></textarea>
</p>
<p class="col-sm-6 col-md-2 col-xs-12" ">
<br /><br /><br  /><br /><br />
<a id="btnSave"  onclick="SaveValue()" class="btn btn-success btn-flat btn-xs-block"><span style="color: #fff;" class="glyphicon glyphicon-save"></span>Save</a>
</p>

Adding the line break resolved my issue completely. Thank you!

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

Turn off hover functionality for mobile and tablet devices

Is there a way to prevent hover effects on mobile and tablet devices for an SVG file used in the img tag? scss file: .menu-link:hover { img { filter: invert(40%) sepia(90%) saturate(2460%) hue-rotate(204deg) brightness(93%) contrast(93%); } .side ...

iOS Safari browser does not support changing the caret color in textarea

Seeking a solution to hide the text cursor (caret) from a textarea on iOS browsers like Safari and Chrome. Despite trying the caret-color property, it does not seem to work. Are there any alternative methods to achieve this? One approach I attempted is b ...

Stop the image transformation/transition when the back face is not visible

Experience the magic of a box that flips with just a click. Inside, an image awaits to zoom in upon hovering. Check out this sample. The only glitch is that the zoom transition on the hidden image appears for a brief moment when I move my mouse out or ba ...

Prevent the use of repetitive borders by utilizing display: inline-block

I've been experimenting with the behavior of div elements when used as a table, rather than using the traditional table element or display properties. The main reason for this is that I have found tables and display properties to be problematic for my ...

The drop-down arrow in the <select> element seems determined to stay within the container

I am currently exploring alternative solutions (without the use of JavaScript) to address a Firefox bug that prevents styling the dropdown arrow in select elements. Some sources suggest placing the select element within a container and adjusting the contai ...

Scroll vertically to navigate through sub-menus in the menu bar

My goal was to design a vertical menu containing numerous sub navigation options, but due to the overwhelming number of sub nav items, it exceeds the size of the window. Setting overflow: auto; and a specific height resolves this issue, however, the third ...

"Utilize CSS for animating list items within a ul

Having an unordered list, I would like to iterate through each list item one by one. My current solution is somewhat functional, but upon close inspection, you can observe that when it reaches "item 4," it starts overlapping with "item 1" and becomes incon ...

What is the best way to position the text diagonally while keeping the letters arranged horizontally?

My current challenge involves achieving a specific design element. For instance, I am looking to position an h1 tag diagonally on the screen while keeping the individual letters horizontally aligned. I have experimented with various methods, such as wrapp ...

What is the method of generating an HTML tag solely using CSS?

Looking to style HTML tags without altering them in any way? Consider this example: <div id="Code_G" class="editor-group"> editor-group<br /> <div id="Code_L" class="editor-label "> editor-label </div> < ...

Using SVG and CSS to color multiple paths with individual colors

I am working with an svg that contains various paths, ellipses, and shapes each with different fill colors such as red and blue. When I combine them into a sprite, I want to be able to change the fill color on hover using CSS. Typically, I would remove the ...

Exploring the power of Angular by implementing nested ng-repeat functionalities:

I am currently working on an ng-repeat feature to add items from the array (album array). Everything seems to be functioning correctly. However, I also have a colors array that should assign different background-colors to the card elements of the album arr ...

Tips for updating the hover background color of a table row with a unique class in bootstrap

Modified: Here is the table along with its corresponding CSS styling: .table-hover tbody tr:hover { background-color: #fff !important; } <html lang="en"> <head> <meta charset="utf-8" /> <meta name="v ...

Issues with Jquery datatable causing column header to overlap the table header

I am facing an issue with my datatable as the table is not displaying correctly. Could someone advise me on how to troubleshoot and fix this problem? Below is the code snippet in question: $(tbName).dataTable({ "sScrollX": "100%", "sScro ...

I desire for my div elements to stack on top of each other

Struggling to get my images to overlap no matter what positions I try. HTML Code: <li class="six"> <img class="06a" src="../inhouds/images/page06a.png"> <img class="06b" src="../inhouds/images/page06b.png"> <img class="06c" src=".. ...

Divs should be of consistent and adjustable height

I am in need of a layout with three columns: left column (with a red background) center column (with a yellow background) right column (with a black background) This is the HTML structure I have in mind: <div id="container"> <div id="left_ ...

Tips on creating CSS for an element with certain text within it?

I have a text element List that I need to select. Instead of using xpath like - //li[text()='List'] I want to use css. How can I write css for this? I attempted the following after referring to but it didn't work. li:contains('List& ...

Ajax request unable to load Image Slider

I'm currently implementing an Image Slider from this source For the site structure, I've set up an index.html file to display all the pages, allowing navigation by changing the content within <div id="isi">. Here's a snippet of the in ...

TailwindCSS in React.Js does not seem to accept randomly generated color codes

Check out my Messages component below: import randomColor from "random-color"; import React from "react"; import "../Chat.css"; function DisplayMessage({ username, message }) { const changeTextColor = randomColor(0.99, 0.99 ...

Creating a combined Email and Password form field in a single row using Bootstrap

Recently, I decided to explore bootstrap. I am looking to implement email/password validation in one row on my rails app: email? | password? | OK Currently, I have a functioning code for displaying only an email field and an OK button in one row: email? ...

What is the best way to remove a CSS style using JavaScript?

For my website automation using Selenium, I encountered a challenging dropdown that was not the standard native one but a custom-designed version. To tackle this issue, I needed to set its CSS class to hidden in order to access the native functionality smo ...