Center text within a div

-1

You see, I have a table Game with the following values:

Schema::create('juegos', function (Blueprint $table){
        $table->increments('id');
        $table->integer('numero')->unique();
        $table->string('nombre');
        $table->unsignedInteger('agrupacion_id');
        $table->foreign('agrupacion_id')->references('id')->on('agrupacions');
        $table->text('materiales');
        $table->text('organizacion');
        $table->text('desarrollo');
        $table->string('foto');
        $table->text('observaciones');
        $table->text('variantes');
        $table->timestamps();
    });

And the data of a game is shown in the following view:

@extends('layouts.app')

@section('content')
    <h1 class="text-center text-mute"><u>Datos del juego</u></h1>

    <div class="pl-5 pr-5">
        <div class="row justify-content-center">
        <div class="col-md-3 card card-1">
            <h2 class="text-center card-title">Nº {{$j->numero}}: {{$j->nombre}}</h2>
            <img class="card-img-top" src="{{url($j->ruta())}}"/>
            <div class="card-body">
                <center>
                    <span class="badge badge-cat badge-info">Materiales necesarios: {{$j->materiales}}</span>
                    <span class="badge badge-cat badge-info">Organcización de equipos: {{$j->agrupacion->nombre}}</span>
                </center>

                <hr>

                <h3>Posicionamiento:</h3>
                <span class="badge badge-cat badge-primary">{{$j->organizacion}}</span>

                <hr>

                <h3>¿En que consiste?</h3>
                <span class="badge badge-cat badge-primary">{{$j->desarrollo}}</span>

                <hr>

                <h3>Normas:</h3>
                <span class="badge badge-cat badge-primary">{{$j->observaciones}}</span>

                <hr>

                <h3>Variaciones:</h3>
                <span class="badge badge-cat badge-primary">{{$j->variantes}}</span>

                <hr>

                <?php
                    $contenidos=$j->enlaces;
                ?>

                @if(count($contenidos))
                    <h3>Habilidades que seran puesta a prueba de los participantes:</h3>
                    @foreach($contenidos as $contenido)
                        <span class="badge badge-cat badge-info">{{$contenido->contenido->nombre}}</span>
                    @endforeach
                @endif
            </div>
        </div>
        </div>
    </div>
@endsection

And when creating a game, I see myself with this:

I need that the content of the texts do not leave the div. How do I achieve it?

Edit: I have left only badge-primary, and I find this:

At last there are line breaks, but I would like more space between the bluish background and the text, because up and down there is a good space, but from left to right this does not exist that spacing.

I've also tried class="alert alert-info":

But it does not look good at all.

Another thing I've tried is class="btn-primary", giving me the same result as badge-primary. I've also tried class="alert-primary", which gives the following result:

It looks better, but I still have the same problem as with btn-primary and badge-primary, that the bluish background does not give space between the letter and the white background.

    
asked by Miguel Alparez 11.07.2018 в 11:35
source

3 answers

1

The problem is that you are using the category .badge of bootstrap and this by default contains the white-space: nowrap; property that makes the text look like this

The best thing is that you change all that class for a different one, for example class="alert alert-info"

    
answered by 11.07.2018 в 11:42
1

Have you already tried paragraphs?

<h3>Posicionamiento:</h3>
<p>{{$j->organizacion}}</p>
    
answered by 11.07.2018 в 15:39
-1

I will explain what I have done at the end.

This is the new view:

@extends('layouts.app')
@section('content')
    <h1 class="text-center text-mute"><u>Datos del juego</u></h1>

    <div class="pl-5 pr-5">
        <div class="row justify-content-center">
        <div class="col-md-3 card card-1">
            <h2 class="text-center card-title">Nº {{$j->numero}}: {{$j->nombre}}</h2>
            <img class="card-img-top" src="{{url($j->ruta())}}"/>
            <div class="card-body">

                <hr>
                <center>
                    <span class="badge badge-cat badge-info">Materiales necesarios: {{$j->materiales}}</span>
                    <span class="badge badge-cat badge-info">Agrupación de los jugadores: {{$j->agrupacion->nombre}}</span>
                </center>
                <hr>

                <h3>Organización:</h3>
                <p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->organizacion}}</p>

                <h3>Desarrollo del juego</h3>
                <p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->desarrollo}}</p>

                <h3>Reglas y observaciones:</h3>
                <p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->observaciones}}</p>

                @if(!empty($j->variantes))
                    <h3>Variantes:</h3>
                    <p class="badge-primary" style="float: left; padding-left: 5px; padding-right: 4px; border-radius: 5px;">{{$j->variantes}}</p>
                @endif

                <?php
                    $contenidos=$j->enlaces;
                ?>

                @if(count($contenidos))
                    <h3>Habilidades que seran puesta a prueba de los participantes:</h3>
                    <center>
                        @foreach($contenidos as $contenido)
                            <span class="badge badge-cat badge-info">{{$contenido->contenido->nombre}}</span>
                        @endforeach
                    </center>
                @endif

            </div>
        </div>
        </div>
    </div>
@endsection

And it gives this result:

    
answered by 11.07.2018 в 15:49