Center texts in DomPDF

1

I have the following form:

@include('layouts.estilo')
<h1 class="text-center card-title">{{$articulo->titulo}}</h1>
<hr>
<img class="card-img-top" src="{{url($articulo->foto->ruta())}}"/>
<hr>
<h3 class="text-left">{{$articulo->texto}}</h3>
<hr>
<center>
    <span class="badge badge-cat badge-info">Noticia publicada por {{$articulo->user->nombre()}}</span>
    <br>
    <span class="badge badge-cat badge-info">Esta noticia ha sido publicada el {{$articulo->created_at}}</span>
    @if($articulo->created_at<$articulo->updated_at)
        <br>
        <span class="badge badge-cat badge-info">Fue actualizada por última vez el {{$articulo->updated_at}}</span>
    @endif
</center>

This code will be used to print a PDF document, which gives me this result:

Most is fine, but as I have shown in the underlined part, the center tag is not working.

How do the texts center?

PS: In this form I import the file estilo.blade.php , which has this code:

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Slabo+27px" rel="stylesheet">
</head>

Apart, I noticed that the title, which is the h1 tag, is well centered. When trying to replace <center> with <div class="text-center card-title"> , fail again. Moreover, I have verified that if the texts are centered when removing from <span> the part of class="badge badge-cat badge-info" . When using a normal view they did not give any problem, but when passing it to PDF it collides with the centering of the text.

    
asked by Miguel Alparez 31.10.2018 в 10:21
source

1 answer

0

Put it in a div .

Example:

<div style="text-align: center;">contenido a centrar</div>
    
answered by 31.10.2018 в 10:24