0

I am beginner in magento 2, I want to add a style CSS for my Block but it does not work, here is the code:

 <head>
 <css src="Managys_Pricing::css/style.css"/>
</head>
<update handle="editor"/>
<body>
 <referenceContainer name="content">
 <block class="Managys\Pricing\Block\Adminhtml\Configuration\Edit" name="pricingadmin_configuration_edit"/>
 </referenceContainer>
 <referenceContainer name="left">
 <block class="Managys\Pricing\Block\Adminhtml\Configuration\Edit\Tabs" name="pricingadmin_configuration_edit_tabs"/>
 </referenceContainer>
</body>

At the level of Block\Adminhtml\Configuration\Edit\Tab I added column_css_class

$fieldset
 ->addField(
 'date_update',
 'label',
 [
 'label' => __("Dernière mise à jour des prix :" .$configuration["last_price_update"]),
 'column_css_class' => 'date_update'
 ]
 );

And I put in the css file,

.date_update{
width: 500px;
 }

enter image description here

I do not know if as the continuation or no. Thank you to help me!

Amrit Pal Singh
1,6381 gold badge17 silver badges36 bronze badges
asked Jan 11, 2018 at 9:11
8
  • where is youer css file? Path For JS::View/Frontend/Web/Js Path For Css::View/Frontend/Web/Css Commented Jan 11, 2018 at 9:35
  • for the css file I put it in view/adminhtml/web/css Commented Jan 11, 2018 at 9:41
  • run this comand :: php bin/magento setup:static-content:deploy Commented Jan 11, 2018 at 9:43
  • Or youcan can check your formate $this->addColumn( 'product_id', [ 'header' => __('Select Product'), 'sortable' => false, 'type' => 'checkbox', 'field_name' => 'product_id[]', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id' ] ); Commented Jan 11, 2018 at 9:50
  • Label is display properly? Commented Jan 11, 2018 at 9:53

1 Answer 1

0

Store your Css in

App/Code/Vendor/Module/View/Location/Web/css

Ans Store js in

App/Code/Vendor/Module/View/Location/Web/js

in your layout

<!-- for css file -->
 <css src="Vendor_Module::css/grid.css"/>
 <!-- for js file -->
 <script src="Vendor_Module::js/grid.js"/>

then run comand => php bin/magento setup:static-content:deploy

answered Jan 11, 2018 at 9:39
2
  • I run this comand php bin/magento setup:static-content:deploy but it appears an error: NOTE: Manual static content deployment is not required in "default" and "de veloper" modes. In "default" and "developer" modes static contents are being deployed autom atically on demand. If you still want to deploy in these modes, use -f option: 'bin/magento set up:static-content:deploy -f Commented Jan 11, 2018 at 10:09
  • no problem youcan use bin/magento set up:static-content:deploy -f and your path is right view/adminhtml/web/css don change Commented Jan 11, 2018 at 10:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.