0

I am trying to increase the width of a column in a SharePoint Online List Web Part. Unfortunately, none of the suggestions offered in StackExchange work for me. I have been adding JavaScript in a Modern Script Editor Web part as shown below but it is not increasing the width of the column.

<style type="text/css">
.ms-DetailsHeader-cell
{
      width: 310px; 
}

enter image description here

1
  • modern or classic? Some stuff simply cannot be changed with script hacks.
    – teylyn
    Sep 15, 2020 at 1:36

1 Answer 1

0

It's not recommend to create or add ungoverned code on modern SharePoint pages, you need to get started with SPFx:

https://sharepoint.uservoice.com/forums/329214-sites-and-collaboration/suggestions/17290130-bring-back-script-editor-web-part-in-modern-shar

You could consider using json formatting as shown below to increase the width of list column:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "color": "green",
    "width": "300px"
  }
}

Result:

enter image description here

Reference:

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting

Your Answer

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

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