Button does not show full name

Asked

Viewed 128 times

1

I have several buttons inside my divs. I leave the css that I use to put the div side by side and the css to set the size of all buttons so that they are all the same. But then I have the problem when the text is a little bigger as shown in the images below surrounded in red.

.div { 
width: calc(50% - 0px);
margin: 0%;
float: left;
}
.div.div1 { 
float: right;
}
.botao{
width:70%
}

<button class="btn btn-info btn-sm botao" onclick="inserir_registo9();if(confirm('Pretende registar esta atividade?')) this.disabled=true;">Mudança de Fralda+Cama+Roupa</button>

but only shows the following text on the button on your phone: inserir a descrição da imagem aqui

but if it’s on the computer screen it already shows the full text: inserir a descrição da imagem aqui

The idea is to put all buttons with the same size as this, be Divs and responsive buttons, but on the phone also wanted to view the full content.

HTML:

<div class="table-responsive">  
<?php
$user = (!empty($_GET['codigo'])) ? $_GET['codigo'] : '';
?>
<input type="hidden" id="codigo" name="codigo" value="<?php echo htmlentities( $user ) ; ?>" /> 
<div class="form-group">
<label for="IniciarTarefa" id="acao"></label>
<button type="button" class="btn btn-warning" onclick="myFunction()">Iniciar Tarefa</button>
<input type="hidden" id="IniciarTarefa" name="IniciarTarefa"/>
<input type="hidden" name="Colaborador" id="Colaborador" value="<?php echo $_SESSION['usuarioNome']; ?>">
</div> 

<div class="form-group">
<input type="hidden" id="tarefa" name="tarefa" value="Lateral Direito">
<button type="button" class="btn btn-info btn-sm botao" onclick="inserir_registo();if(confirm('Pretende registar esta atividade?')) this.disabled=true;">Lateral Direito</button><button type="button" name="abrir"><span class="glyphicon glyphicon-comment"></span></button>
<div class="form-group" id="comentario" style="display:none">
<textarea id="Observacao" name="Observacao" style="color: black;"></textarea>
</div>
</div>

<div class="form-group">
<input type="hidden" id="tarefa1" name="tarefa" value="Lateral Esquerdo">
<button class="btn btn-info btn-sm botao" onclick="inserir_registo1();if(confirm('Pretende registar esta atividade?')) this.disabled=true;">Lateral Esquerdo</button><button type="button" name="abrir1"><span class="glyphicon glyphicon-comment"></span></button>
<div class="form-group" id="comentario1" style="display:none">
<textarea id="Observacao1" name="Observacao" style="color: black;"></textarea>
</div>
</div>
</div>
  • is its width: 70%, it limits the size of the button and what leaks it gets hidden. strip the width of the button and put only a max-width if necessary, to set a maximum size and the minimum undefined.

  • @Eliseu B. But this way the buttons do not all stay the same size and intended to put the buttons all the same size to have a good presentation. How can I do it?

  • First put your HTML tb in the question, it seems that you use Bootstrap 3, but somehow you are using Grid Col-* the wrong way, if you are using... Another thing, what is your idea to show the whole text? Decrease the font? Put the text in the whole line? More details of what you really want to do

  • 1

    In your case you leave a column per row is ideal, because so has many elements for little space, and will be even more pleasant to navigation, I left below a brief demonstration of use of fixed and fluid widths for the elements.

  • @hugocsl added part of my html

  • Face but you also have to say what you want, as you want to put 10 words where only fit 5? What is your idea, hide part of the text, instead of 2 per line put 1 per line to have more space for text. You have to give detail so we don’t waste time answering something you don’t want

  • @hugocsl my idea was to tone the button wider, as if it had two lines and appeared one part of the text above and another below. I forgot to mention that detail

Show 2 more comments

2 answers

4


The main problem is that the class btn of Bootstrap 3 puts attribute white-space: nowrap; and this does not let the text break line inside the button.

inserir a descrição da imagem aqui

So since you put the class .botao add there the property white-space: normal;, because then the text will go on to break the line.

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Page Title</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" media="screen"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" media="screen"
    href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
  <style>
    .div {
      width: calc(50% - 0px);
      margin: 0%;
      float: left;
    }

    .div.div1 {
      float: right;
    }

    .botao {
      width: 70%;
      white-space: normal;
    }
  </style>
</head>

<body>

  <div class="container">
    <div class="row">
      <input type="hidden" id="codigo" name="codigo" value="<?php echo htmlentities( $user ) ; ?>" />
      <div class="form-group">
        <label for="IniciarTarefa" id="acao"></label>
        <button type="button" class="btn btn-warning" onclick="myFunction()">Iniciar Tarefa</button>
        <input type="hidden" id="IniciarTarefa" name="IniciarTarefa" />
        <input type="hidden" name="Colaborador" id="Colaborador" value="<?php echo $_SESSION['usuarioNome']; ?>">
      </div>

      <div class="form-group">
        <input type="hidden" id="tarefa" name="tarefa" value="Lateral Direito">
        <button type="button" class="btn btn-info btn-sm botao"
          onclick="inserir_registo();if(confirm('Pretende registar esta atividade?')) this.disabled=true;">Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem possimus recusandae optio totam quasi ipsa aperiam neque saepe porro pariatur. Impedit non commodi accusamus totam! Architecto veritatis est molestias deserunt.
          Direito</button><button type="button" name="abrir"><span class="glyphicon glyphicon-comment"></span></button>
        <div class="form-group" id="comentario" style="display:none">
          <textarea id="Observacao" name="Observacao" style="color: black;"></textarea>
        </div>
      </div>

      <div class="form-group">
        <input type="hidden" id="tarefa1" name="tarefa" value="Lateral Esquerdo">
        <button class="btn btn-info btn-sm botao"
          onclick="inserir_registo1();if(confirm('Pretende registar esta atividade?')) this.disabled=true;">Lateral
          Esquerdo</button><button type="button" name="abrir1"><span
            class="glyphicon glyphicon-comment"></span></button>
        <div class="form-group" id="comentario1" style="display:none">
          <textarea id="Observacao1" name="Observacao" style="color: black;"></textarea>
        </div>
      </div>
    </div>
  </div>

  <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>

</html>

  • that’s just what I was looking for

  • @Bruno nice that it worked out there!

3

I left some examples on the use of width in CSS, check the behavior of them outside of your layout, in the case below I did not hide the contents leaked (the title), and rather broke line, but in the case of your code it hides, and to stay with such a size for all, make use of min-width as demonstrated below:

.container {
  width: 200px;
  background-color: aqua;
}
.a1, .a2, .a3, .a4{
  background-color: #FDBB40;
  padding: 8px 6px;
  margin-top: 10px;
  margin-bottom: 10px;
  font-size: 12px;
}
.a2{
  width: 50%;
}
.a3{
  max-width: 90%;
}
.a4{
  min-width: 90%;
}
<div class='container'>
  <div class='a1'>Botão sem width definido</div>
  <div class='a2'>Botão com width definido</div>
  <div class='a3'>Botão com max-width definido</div>
  <div class='a3'>Botão com min-width definido</div>
</div>

  • ok, that was the initial shape I had. I’ll put it this way

Browser other questions tagged

You are not signed in. Login or sign up in order to post.