Bootstrap模态是透明的 - 不透明度不起作用

时间:2015-08-09 00:40:21

标签: jquery css twitter-bootstrap

我正在使用Bootstrap和Modals atm并且不知道我做错了什么

http://i.stack.imgur.com/HCKnC.png

如您所见,模态内容是透明的,看起来并不好...... 那我该怎么办呢?

<div id="changeRPGNameModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            <h4 class="modal-title">Name ändern:</h4>
        </div>
        <div class="modal-body">
            <div class="form-group">
                <label for="inputRPGName">Name</label>
                <input type="text" class="form-control" id="inputRPGName"
                       placeholder="Gib einen neuen Namen ein" autofocus/>
            </div>
            <div class="containerButtons">
                <button class="floatLeft btn btn-default btn48Percent" data-dismiss="modal">Abbrechen</button>
                <button class="floatRight btn btn-success btn48Percent" data-dismiss="modal" id="buttonChangeRPGName">Ändern</button>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>

我已经尝试在.modal-backdrop(.fade.in)上设置不透明度但如果我这样做,我的屏幕的整个背景都会变白 http://i.stack.imgur.com/zhqbU.png

2 个答案:

答案 0 :(得分:1)

你去了,你在内容加载之前关闭<div class="modal-content">所以内容加载到模态体外Opacity not working,我还为模态标题添加了<div class="modal-content">

<div id="changeRPGNameModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
    <div class="modal-content">
        <div class="modal-header">            
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">Name ändern:</h4>
        </div>
        <div class="modal-body">
            <div class="form-group">
                <label for="inputRPGName">Name</label>
                <input type="text" class="form-control" id="inputRPGName"
                       placeholder="Gib einen neuen Namen ein" autofocus/>
            </div>
            <div class="containerButtons">
                <button class="floatLeft btn btn-default btn48Percent" data-dismiss="modal">Abbrechen</button>
                <button class="floatRight btn btn-success btn48Percent" data-dismiss="modal" id="buttonChangeRPGName">Ändern</button>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
</div>      
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#changeRPGNameModal">Open Modal</button> 

Working Fiddle

答案 1 :(得分:0)

在开发模态时...

您应该使模式背景透明而不是整个模式内容透明。

最简单的解决方案是...而不是更改United Kingdom的值,而是使用opacity更改背景色。

即而不是做

rgba()

照做

background : #000000;
opacity: 0.8;

此解决方案可防止模式内容具有不希望的透明效果。