Skip to content

Instantly share code, notes, and snippets.

@tecchan1107
Last active June 21, 2025 22:34
Show Gist options
  • Save tecchan1107/5c5f9a9b53abd8b053e07f8b2e285637 to your computer and use it in GitHub Desktop.
Save tecchan1107/5c5f9a9b53abd8b053e07f8b2e285637 to your computer and use it in GitHub Desktop.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
"hideSelection": true,
"hideColumnHeader": true,
"rowFormatter": {
"elmType": "div",
"style": {
"width": "=@window.innerWidth*0.9+'px'",
"display": "flex",
"justify-content": "center",
"margin": "20px"
},
"children": [
{
"elmType": "div",
"style": {
"width": "90%",
"position": "relative",
"display": "flex",
"justify-content": "start"
},
"attributes": {
"class": "ms-bgColor-themeLighter"
},
"children": [
{
"elmType": "img",
"style": {
"width": "100%",
"height": "100%",
"position": "absolute",
"object-fit": "cover",
"display": "=if([$Image],'','none')"
},
"attributes": {
"src": "=getThumbnailImage([$Image],1000,1000)"
}
},
{
"elmType": "div",
"style": {
"display": "flex",
"flex-direction": "column",
"background-color": "rgba(0,0,0,0.5)",
"padding": "30px 20px",
"min-width": "250px",
"width": "40%",
"position": "relative",
"margin": "30px",
"text-align": "left"
},
"children": [
{
"elmType": "div",
"txtContent": "[$Category]",
"style": {
"margin-bottom": "8px",
"display": "=if([$Category],'','none')"
},
"attributes": {
"class": "ms-fontColor-white ms-fontSize-m"
}
},
{
"elmType": "div",
"txtContent": "[$Title]",
"style": {
"display": "=if([$Title],'','none')"
},
"attributes": {
"class": "ms-fontColor-white ms-fontSize-xxl"
}
},
{
"elmType": "div",
"txtContent": "[$Description]",
"style": {
"margin-top": "5px",
"display": "=if([$Description],'','none')"
},
"attributes": {
"class": "ms-fontColor-white ms-fontSize-l"
}
},
{
"elmType": "div",
"style": {
"display": "=if([$ButtonText]==''||[$URL]=='','none','flex')",
"margin-top": "15px",
"justify-content": "start"
},
"children": [
{
"elmType": "a",
"txtContent": "[$ButtonText]",
"style": {
"text-decoration": "none",
"padding": "8px 15px",
"border-radius": "5px"
},
"attributes": {
"href": "[$URL]",
"target": "_blank",
"class": "ms-bgColor-white ms-fontColor-themePrimary ms-fontWeight-bold ms-bgColor-gray30--hover ms-fontSize-m"
}
}
]
}
]
}
]
}
]
}
}
@tecchan1107
Copy link
Author

image

image

@tecchan1107
Copy link
Author

Changing justify-content to center on line 19 will center the content horizontally.

image

Also, setting text-align: center on line 50 and justify-content: center on line 90 will center the inner content.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment