Having trouble aligning page in the center with flexbox and styled components

Hey there, I'm having some trouble figuring out how to center my page using flexbox within styled components in a Next.js app. Any suggestions or tips?

Let me share with you my Blog Component

import ReactMarkdown from 'react-markdown'
import BlogPostStyles from './styles/BlogPostStyles';

const BlogComponent = ({ data: { post: { fields: { title, body } } } }) => {
    return (
        <BlogPostStyles>
            <article>
                <ReactMarkdown>{body}</ReactMarkdown>
            </article>
        </BlogPostStyles>
    );
};

export default BlogComponent;

And here is my BlogStyles Component

import styled from 'styled-components';
    
const BlogPostStyles = styled.div`
    max-width: 1200px;
    display: flex;
    justify-content: center;
`;
    
export default BlogPostStyles;

Answer №1

include justify-content:center

experiment with max-width:100%

consider adding min-height:100vh

within the BlogPostStyles section

this issue seems to be related to CSS rather than Next.js :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error 404: Unable to locate webpack bundle.js

As I dive into learning about Webpack configuration, I keep encountering errors in my console. It appears that my webpack app.bundle.js file is not being found. The page successfully loads with the content of my HTML file displaying, but the app.bundle.js ...

Adjusting the display property using the CSS plus symbol operator

I am currently in the process of designing a dropdown menu using CSS. The focus is on utilizing the following code snippet: #submenu_div { display: none; } #li_id:hover + #submenu_div { display: block; } UPDATE: Here is the corrected HTML structure ...

The navigation bar buttons in my IONIC 2 app are unresponsive on both the

In Ionic 2 for Android, I encountered an issue with the title placement. To resolve this, I applied some CSS to center the title and added left and right buttons to the nav bar. However, when I tried to implement onclick functionality for these buttons, no ...

The issue of size with 'First Load JS' in Next.js resolved by utilizing immutable.js

Currently in my Next.js v10 project, I am utilizing the immutable library to interact with redux. However, I have come across an optimization issue involving the initial loading of javascript, which appears as "red." While I am still relatively new to thi ...

Enhancing Material UI datepicker with custom CSS styles, including cursor pointer effects

I am facing an issue with my Material UI datepicker component in React. The cursor is not showing and the icon I added is not clickable, resulting in the datepicker dialog not appearing. Despite trying inline styling and styled-components, I have been una ...

Start the CSS3 animation in reverse right away

I am trying to achieve a "flashing" effect by adding the .shown class to my #overlay, causing the opacity to fade in for 2 seconds and then immediately reverse, fading out for another 2 seconds. After experimenting with removing the class, I found that it ...

Unable to modify font selection in NextUI for NextJS

I am currently utilizing Nextjs 14 with NextUi for the UI library. The app was set up using: npx create-next-app -e https://github.com/nextui-org/next-app-template However, despite my efforts to modify the fonts in font.ts, the displayed font remains unch ...

Unlocking the Power of Typescript and ReactJS: Maximizing Efficiency with Previous State

I'm encountering difficulties implementing the previous state in React 18 with Typescript version 4.8.3. Here is my refreshToken code and I'm receiving the following error: Value of type '(prev: any) => any' has no properties in c ...

Selecting multiple items from a grid using the Ionic framework

I am looking to create a grid of category images in Ionic framework, where users can select multiple categories and send their values to the controller. However, I'm unsure about how to make this happen with Ionic framework. Below is the view I curre ...

Encountering a problem with the navigation bar in the latest version of Next.js, version 13

"use client" import {Navbar, Button, Link, Text} from "@nextui-org/react"; import {styled} from "@nextui-org/react" const Box = styled("div", { boxSizing: "border-box", }); const AcmeLogo = () => ( ...

What is the best way to utilize nav and main-nav in CSS?

Working with HTML and CSS <nav class="nav main-nav"> </nav> Styling with CSS main-nav li{ Padding:0 5% } I am a beginner in HTML and CSS and facing an issue. I noticed that when using main-nav in CSS, I'm not getting the de ...

Creating a live streaming application - A step-by-step guide

I am embarking on a project to develop an application that displays real-time data using React. I have made the decision to utilize Pusher for managing this real-time data, along with exploring open third party APIs for retrieving information. For instance ...

Utilizing JavaScript to trigger an alert message upon selecting various options and blocking the onclick event

Setting up a simpleCart(js) with selectable options presents a challenge. The task at hand is to display an alert if not all drop-downs meet specific requirements and to prevent the "Add to cart" button from adding items to the cart when these conditions a ...

How can I send a current variable through PHP?

I have a pressing deadline and I need some guidance before moving forward. Can someone please advise if what I'm attempting is feasible or if there's a quicker solution? I encountered some problems with an accordion menu, so as a temporary fix, ...

Instructions for designing a Loading Indicator or Progress Bar within the App Directory of NextJS

Having built a substantial web application using NextJS 13, I initially utilized the Pages Router. However, as I neared completion of the website, I decided to make the switch to the App Directory. The primary motivation behind this migration was not just ...

Having trouble getting my Win and Lose Divs to display in my IF statement within the Card Game

Currently, I am developing a card game where players are presented with a card generated by the computer. The player has to decide whether the next card will be higher, lower, or equal to the current one by clicking corresponding buttons. if ((playerChoic ...

Error in hyperlink connection for mapped elements in Next.js

How can I conditionally wrap a link around a component in React? Post.tsx const Post: React.FC<PropsType>=({ id, timestamp, tweet, name, image, creatorId, currUserId, likedBy, retweetedBy }) => { return ( <Link href={` ...

The issue persists with FastAPI CORS when trying to use wildcard in allow origins

A simplified representation of my code utilizing two different approaches. from fastapi import FastAPI middleware = [ Middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=False, allow_methods=["*"], ...

What is causing the issue with useForm not being identified as a function?

error image Why is this error occurring when attempting to use useForm: ⨯ src\app\journal\page.tsx (18:53) @ useForm ⨯ TypeError: (0 , react_hook_form__WEBPACK_IMPORTED_MODULE_5__.useForm) is not a function at Page (./src/app/journal/pa ...

When we typically scroll down the page, the next section should automatically bring us back to the top of the page

When we scroll down the page, the next section should automatically bring us back to the top of the page without having to use the mouse wheel. .bg1 { background-color: #C5876F; height: 1000px; } .bg2 { background-color: #7882BB; height: 1000px; } .bg3 ...