bootstrap模型框背景不透明而不是全屏

时间:2017-07-24 05:44:00

标签: html css bootstrap-modal imagebutton

我尝试将引导模式框链接到图像按钮。单击图像按钮时将显示模式框。任何人都知道如何使模态框的背景透明和全屏?

这是我的html文件

<!DOCTYPE html>
<html>
<style>
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.modal-dialog {
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
}
.modal-content {
    height: 100%;
    min-height: 100%;
    height: auto;
    border-radius: 0;
}
</style>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/ionic.min.css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <title>Add an item</title>

</head>
<body onload="selectCategory()">
<div class="bar bar-header">
    <a href="index.html" class="button button-clear button-royal">Back</a>
    <h1 class="title">Add Item</h1>

</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
            </div>
            <div class="modal-body">
                ...
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>

<div class="padding" style="margin-top:75px;">
    <label class="item-input">
        <input name="photo1" id="photo1" type="image"
               src="images/photo-icon.png"
               onclick=""
               width="20%"
               data-toggle="modal" data-target="#myModal"/>

        <input name="photo2" id="photo2" type="image"
               src="images/photo-icon.png"
               onclick=""
               width="20%"  />

        <input name="photo3" id="photo3" type="image"
               src="images/photo-icon.png"
               onclick=""
               width="20%"  />

        <input name="photo4" id="photo4" type="image"
               src="images/photo-icon.png"
               onclick=""
               width="20%"  />

        <input name="photo5" id="photo5" type="image"
               src="images/photo-icon.png"
               onclick=""
               width="20%"  />
    </label>

    <label class="item-input">
        <span class="input-label">Item Name</span>
        <input type="text" placeholder="" id="itemName">
    </label>
    <label class="item-input">
        <span class="input-label">Category</span>
        <select id="select_category" name="select_category">
            <option value="0">- Select -</option>
        </select>
    </label>
    <label class="item-input">
        <span class="input-label">Price</span>
        <input type="number" placeholder="" id="price">
    </label>


    <label class="item-input">
        <button class="button button-block button-positive" id="addProduct">Add item</button>
    </label>


</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jq.js"></script>
<script type="text/javascript" src="js/addProduct.js"></script>

</body>

</html>

这是我点击图片后的输出 enter image description here

5 个答案:

答案 0 :(得分:0)

如果您希望模态的外部区域变为白色。

然后使用:

.modal-open .modal{
   background: #fff !important;
}

答案 1 :(得分:0)

我找到了解决方案。将其添加到css部分

.fade.in {background-color: transparent;}

答案 2 :(得分:0)

.modal-backdrop.in {
background: rgba(0, 0, 0, 0.5);
}
.modal-dialog {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.modal-content {
  height: auto;
  min-height: 100%;
  border-radius: 0;
}

答案 3 :(得分:0)

只需添加以下代码:

<style>

.modal-backdrop.in{
opacity: 0 !important;
}

</style>

答案 4 :(得分:0)

我建议使用这个..

    .modal-backdrop.in {
background: rgba(0, 0, 0, 0.5);
}
.modal-dialog {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.modal-content {
  height: auto;
  min-height: 100%;
  border-radius: 0;
}


I assume you are looking for a lightbox kind of effect in you modal. If so try here some links that can help you further..
https://bootsnipp.com/snippets/7XVM2 
http://ashleydw.github.io/lightbox/ 
https://codepen.io/webcane/pen/bNEOXZ