0
background-color: #55ce63;
color: #fff;
content:<? {{__('trans.On')}} ?>;
padding-right: 14px

this code css in header of blade how to write laravel code in css to change

5
  • content: '{{ __('trans.On') }}';. This will only work on a blade file. Commented Feb 8, 2022 at 14:19
  • what can i do for translate value off css Commented Feb 8, 2022 at 14:22
  • 1
    what do you mean by translate value off css ? Commented Feb 8, 2022 at 14:27
  • You cannot use php/blade in your css file, You can use css variables or style in your blade layout Commented Feb 8, 2022 at 14:31
  • You can provide translations in the lang folder, not translate arbitrary strings Commented Feb 8, 2022 at 15:00

2 Answers 2

2

You can't use php or blade in your css file, but you can set a css variable in your .blade.php file as a style attribute:

style="--content-on: '{{ __('trans.On') }}';" 

And use that variable in your css file:

content: var(--content-on);
Sign up to request clarification or add additional context in comments.

1 Comment

@AbdelkawySalah If this answer solved your problem please accept it when you can so it can be closed. Thanks
0

I don't recommend using Laravel variables in the CSS file.

Make your style which you want to style with variables inline style in your blade page.

You can try something like this:

style="color:{{{ $var_name }}}"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.