Home > Software engineering >  Align button to textarea corner
Align button to textarea corner

Time:01-13

I have a text_area and I want a two of buttons to be below the text_area and aligned with the text area's bottom right corner to be like:

expected

What I have so far is below code:

form with modal

<%= form_for @note, :url => registrant_notes_path(@registrant), remote: true do |f| %>
  <div >
    <%= f.label :body, 'Add note' %>
    <%= f.text_area :body, maxlength: 1000, id: "review_text" %>
    <%= show_errors(@note, :body) %>

    <div >
      <span id="counter" data-maximum-length="1000"><%= 1000 %></span> chars left / 1000 character max
    </div>
    <%= f.hidden_field :administrator_id, value: current_login.id %>
    <%= f.hidden_field :registrant_id, value: @registrant.id %>
  </div>
  <div >
    <button type="button"  data-dismiss="modal">Close</button>
    <%= f.submit "Save", class: "btn btn-primary" %>
  </div>
<% end %>

css

.modal-footer {
    border-top: 0 none;
}

.counter-text {
  border-top: 0 none;
  text-align: right;
}

#review_text {
  min-height: 54px;
  width: 100%;
}

CodePudding user response:

add padding-right:0; to .moadal-footer

 .modal-footer {
 border-top: 0 none;
  padding-right:0;
 }

add modal-footer section after div modal-body

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div >
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button"  data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div  id="myModal" role="dialog">
    <div >
    
      <!-- Modal content-->
      <div >
        <div >
          <button type="button"  data-dismiss="modal">&times;</button>
          <h4 >Modal Header</h4>
        </div>
        <div >
          <p>Some text in the modal.</p>
        </div>
        <div  style="padding-right:0">
          <button type="button"  data-dismiss="modal">Close</button>
           <button type="submit" >Submit</button>
        </div>
      </div>
      
    </div>
  </div>
  
</div>

</body>
</html>

end

 <div >
    <button type="button"  data-dismiss="modal">Close</button>
    <%= f.submit "Save", class: "btn btn-primary" %>
  </div>
  •  Tags:  
  • Related