最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Float button right in modal header next to close button - Stack Overflow

programmeradmin1浏览0评论

I have a modal and wanted to add some details and buttons in the header. I have a title and close button. I also want to add another button to the left of the close button. The button keeps floating left even though I have a float-right set up.

My Code:

<div class="modal-header">
                      <h5 class="modal-title"></h5>
                      <div class="float-right">
                        <a id='modal_csv'><i class="fas fa-camera"></i></a>
                      </div>

                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                      </button>
                    </div>

My output:

How do I float the

<div class="float-right">
   <a id='modal_csv'><i class="fas fa-camera"></i></a>
</div>

to the right next to the close button. What am I doing wrong?

I have a modal and wanted to add some details and buttons in the header. I have a title and close button. I also want to add another button to the left of the close button. The button keeps floating left even though I have a float-right set up.

My Code:

<div class="modal-header">
                      <h5 class="modal-title"></h5>
                      <div class="float-right">
                        <a id='modal_csv'><i class="fas fa-camera"></i></a>
                      </div>

                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                      </button>
                    </div>

My output:

How do I float the

<div class="float-right">
   <a id='modal_csv'><i class="fas fa-camera"></i></a>
</div>

to the right next to the close button. What am I doing wrong?

Share Improve this question asked Oct 3, 2019 at 18:25 nb_nb_nbnb_nb_nb 1,38117 silver badges53 bronze badges 2
  • Put the div after the close button. – A. Meshu Commented Oct 3, 2019 at 18:34
  • @A.Meshu, wont the camera link move after the close? I want it before the close and next to it – nb_nb_nb Commented Oct 3, 2019 at 18:47
Add a ment  | 

2 Answers 2

Reset to default 6

I think this is the layout is as you wanted...

I believe you wanted to use pull-right

<link href="https://stackpath.bootstrapcdn./bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare./ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<div class="modal-header">
    <h5 class="modal-title pull-left">Title</h5>

    <div class="pull-right">
        <a id='modal_csv'><i class="fas fa-camera"></i></a>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div> 
</div>

Here is a working example, I have not changed any html, maybe your css is wrong or I'm not understanding.

html {
  font-family: Arial, Helvetica, sans-serif;
}

.modal-title {
  display: inline-block;
}

.modal-header {
  width: 300px;
  height: 60px;
  background: #e6e6e6;
  border-radius: 5px;
  padding: 5px;
}

h5 {
  font-size: 26px;
  margin: 14px 0;
}

.float-right,
.close {
  float: right;
  margin: 20px 4px;
}

i {
  font-size: 22px;
}
<link href="https://cdnjs.cloudflare./ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<div class="modal-header">
  <h5 class="modal-title">Mobile</h5>
  <div class="float-right">
    <a id='modal_csv'><i class="fas fa-camera-retro"></i></a>
  </div>

  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
    <span aria-hidden="true">&times;</span>
  </button>
</div>

发布评论

评论列表(0)

  1. 暂无评论