2016-11-30 92 views
2

当我laravel刀片文件全无类型Laravel 5.3刀片支持<font>标签吗?

<font> test </font> 

铬呈现。

编辑:请不要只是建议不要使用字体标签,阅读整个问题。这个字体标签是由wysiwyg编辑器summernote生成的,所以它不是我选择使用它。

奇怪的是我在页面源中看到这个标签,但它没有在页面上呈现。当我制作具有相同来源的本地HTML文件时,它会在Chrome中的字体标签中显示文字。 另外,当我去开发工具元素,并点击容器div编辑为HTML,如果我在任何地方添加任何东西,然后所有的字体标签突然出现。 Firefox中的行为完全相同。如果我不在督察编辑页面字体标签不显示,无论我刷新多少次。

这里是我的刀片文件:

@extends('layouts.app') 


@section('content') 
    <font> test </font> 
    <p> <a href="/articles"><-Back</a></p> 
    <p> Selected article: {{$article->title}} </p> 
    <p> Description: {{$article->description}} </p> 
    <p><img src="/{{$article->image}}" width="600px" alt="ASD"></p> 
    <font> ojo </font> 
    {!! $article->body !!} 
    <p>ge?</p> 
@stop 
+1

我想你知道它,但是如果你没有... HTML 5中不再支持标记。也许这就是你得到错误的原因。 – GabMic

+0

来阐述GrowingDev,阅读这个@pera:[w3schools](http://www.w3schools.com/TAGs/tag_font.asp)。另外,最好使用''代替CSS。 –

+0

基本上,刀片文件中支持的所有html标签。但是,你的问题与刀片无关。HTML5中不再支持

回答

1

我发现是什么造成了这种行为,我应该更早意识到,如果它看起来像魔法 - 它的JavaScript 。

因此,在基本的Laravel 5.3刀片页面中,我们在源代码中有字体标签,我们可以在页面源代码中看到它,但它们在页面上不可见。原因是因为Laravel 5.3默认包含Vue JavaScript框架,包括包含Vue的app.js,它在文档加载时运行一些Vue魔术,所以字体标签由于某种原因被隐藏 - 可能与被弃用有关。

我现在从我的Laravel应用程序中删除了Vue(通过删除包含它的js代码)并且字体标记又回来了。

1

<font></font>在HTML 4.01的同时,不赞成使用仅涉及所有的造型元素,然后在HTML5废弃。 这与laravel无关。

<font>元素的前一种行为,就可以实现,甚至更好的使用CSS Fonts CSS属性

See more information on <font> here.

编辑

我得到了你的问题错了控制,http://summernote.org/正在生成<font>标签。每当summernote获得输入时您都可以替换它。就像这样:

可能需要一些调整

//some dynamic elements have to be triggered from the body 
 
$body = $(document.body); 
 

 
//container where font excists 
 
$container = $('.container') 
 

 
//less code to type 
 
function observe(element, event, handler) { 
 
    $body.on(event, element, handler) 
 
} 
 

 
//delay 0 to speed up 
 
function delay_func() { 
 
    window.setTimeout(font_to_span(), 0); 
 
} 
 

 
//replace font tags with span and extract the font family 
 
function font_to_span() { 
 
    $font = $container.find('font'); 
 
    font_family = $font.attr('face'); 
 
    $font.replaceWith(function() { 
 
    return $("<span />", { 
 
     html: $(this).html(), 
 
     style: 'font-family:' + font_family + ';' 
 
    }); 
 
    }); 
 
} 
 

 
//add events to trigger font finder_to_span on 
 
observe($container, 'change', font_to_span); 
 
observe($container, 'cut', delay_func); 
 
observe($container, 'paste', delay_func); 
 
observe($container, 'drop', delay_func); 
 
observe($container, 'keydown', delay_func); 
 
font_to_span();
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> 
 
<div class="container">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce feugiat, sapien sed tempor dignissim, mi metus tempor enim, <font face="Comic Sans MS">a vestibulum nulla tortor</font> posuere tellus. Etiam eu dolor ut dui viverra dictum non non justo. Duis 
 
    blandit in enim vitae mollis. Integer euismod lectus ut turpis fermentum, eget rutrum urna ornare.</div>

+0

它与laravel有关,因为如果你用字体标签制作简单的html页面 - 你会看到它很好。 – pera

+0

也许这段代码会帮助吗? –

+0

该代码段很有用,我会用它,我没有找到这个问题的原因。 – pera