引导按钮组合理无效

时间:2018-04-18 19:52:43

标签: html css twitter-bootstrap

我有以下代码:

<div class="btn-group btn-group-justified">
    <a class="btn btn-success" href="{% url 'interface:data' user_id 24 %}"> 24h </a>
    <a class="btn btn-success" href="{% url 'interface:data' user_id 12 %}"> 12h </a>
    <a class="btn btn-success" href="{% url 'interface:data' user_id 4 %}"> 4h </a>
</div>

我得到以下结果:enter image description here

为什么我没有得到这个结果? enter image description here

2 个答案:

答案 0 :(得分:2)

正如其他人所指出的,<div class="**btn-group d-flex**" role="group"></div>在Bootstrap 4中被弃用。在迁移文档中,我们提供了另一种选择:

  

删除 .btn-group-justified 。作为替代,您可以使用<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous"> <div class="btn-group d-flex" role="group"> <a class="btn btn-success w-100" > 24h </a> <a class="btn btn-success w-100" > 12h </a> <a class="btn btn-success w-100" > 4h </a> </div>作为包装    .w-100

的元素

https://getbootstrap.com/docs/4.0/migration/#button-group

利用这个新设置,您的代码将如下所示:

AttributeError                            Traceback (most recent call last)
<ipython-input-24-113069c95a32> in <module>()
     17     answer=tf.convert_to_tensor(answers_train[i], dtype=tf.float32)
     18 
---> 19     grads = grad(model, sent, quest, answer)
     20     optimizer.apply_gradients(zip(grads, model.variables),
     21                             global_step=tf.train.get_or_create_global_step())

<ipython-input-20-21f32f7e2b32> in grad(model, sent, quest, targets)
      2       with tfe.GradientTape() as tape:
      3         loss_value = loss(model, sent, quest, targets)
----> 4         return tape.gradient(loss_value, model.variables)

/Users/sdoneva/anaconda/lib/python3.6/site-packages/tensorflow/python/eager/backprop.py in __exit__(self, typ, value, traceback)
    715 
    716   def __exit__(self, typ, value, traceback):
--> 717     tape.pop_tape(self._tape)
    718 
    719   def watch(self, tensor):

/Users/sdoneva/anaconda/lib/python3.6/site-packages/tensorflow/python/eager/tape.py in pop_tape(tape)
     60 def pop_tape(tape):
     61   """Pops the top tape in the stack, if any."""
---> 62   pywrap_tensorflow.TFE_Py_TapeSetRemove(tape._tape)  # pylint: disable=protected-access
     63 
     64 

AttributeError: 'NoneType' object has no attribute '_tape'

答案 1 :(得分:0)

看起来.btn-group-justified类已从Bootstrap 4中移除(source

只需要一点点CSS就能完成同样的事情:

HTML:

<div class="btn-group btn-group-justified">
    <a class="btn btn-success" > 24h </a>
    <a class="btn btn-success" > 12h </a>
    <a class="btn btn-success" > 4h </a>
</div>

CSS:

a {
   width:100%;
}
div {
   width:100%;
}