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!

8
  • where is youer css file? Path For JS::View/Frontend/Web/Js Path For Css::View/Frontend/Web/Css Jan 11, 2018 at 9:35
  • for the css file I put it in view/adminhtml/web/css
    – lisa
    Jan 11, 2018 at 9:41
  • run this comand :: php bin/magento setup:static-content:deploy 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' ] ); Jan 11, 2018 at 9:50
  • Label is display properly? 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

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
    – lisa
    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 Jan 11, 2018 at 10:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.