在 Laravel blade 文件中使用 css 样式标签

Using css style tag within Laravel blade file

我想在我的 blade.php 文件中使用 css,但我在这样做时遇到了问题。我想避免使用外部 css sheet。在普通的 html 文件中,我可以做这样的事情

<img src="/Users/rays/Desktop/Icons/Joe_Icon.png" style="width:160px;height:100px">

它会为我生成一个图像,resized.I 我试图在 blade 文件中做同样的事情,但遇到了麻烦。

下面的代码显示了一个图像,但它没有将它的样式设置为正确的尺寸,我还在屏幕上看到了 style="width:160px;height:100px" 字样。

<a href="#">{{ HTML::image("progress2/Icons/Joe_Icon.png")}} style="width:160px;height:100px"  </a>

这也会显示图像,但显示的图像尺寸不正确。

  <style="width:160px;height:100px">
  <a href="#">{{ HTML::image("progress2/Icons/Joe_Icon.png")}} </a>
  </style>

下面的语法错误

<a href="#">{{ HTML::image("progress2/Icons/Joe_Icon.png" style="width:160px;height:100px" )}} </a>

试试这个:

{!! HTML::image('progress2/Icons/Joe_Icon.png', 'alt', array( 'width' => 160, 'height' => 100 )) !!}

此外,硬编码 CSS 是一种不好的做法。您应该使用 CSS 样式表并像这样构建图像:

{!! HTML::image('progress2/Icons/Joe_Icon.png', 'alt', array('class' => 'progress_image')) !!}