I'm having trouble aligning my paragraph to the center

I am struggling to center my paragraph text while adjusting the width. Here is the HTML code I am working with:

<section class="sss">
        <div class="s-footer">
            <h3>Like what you see?</h3>
            <p>Hire me</p>
        </div>

        <div class="nav-footer">
            
            <nav class="list">
                <ul>
                    <li><a href="#">My work</a></li>
                    <li><a href="#">My skills</a></li>
                    <li><a href="#">Hire me</a></li>
                </ul>
            </nav>

            <a href="index.html" class="logo-2">Alkhazriji</a>
        </div>
    </section>

Here is my CSS code inside the media query:

.s-footer p
    {
        display: block;
        width: 50%;
        text-align: center;
    }

And before the media query, here is the CSS code:

.s-footer p
{
    background: #852EF8;
    border-radius: 50px;
    margin: 0 5em;
    font-size: 1.5em;
    width: 33.33;
    font-weight: bold;
    color: #FF57E9;
    cursor: pointer;
    display: block;
    position: relative;
}

.sss
{
    padding-top: 0;
    margin-top: 0;
    display: block;
    padding: 0;
}

I have tried various methods like text align, position, grid, and display to center the paragraph text, but when I adjust the width it shifts to the left side. Any advice would be greatly appreciated. (I'm new to coding so please bear with me).

Answer №1

Need help with alignment?

.s-footer p
    {
       display: block;
       width: 50%;
       text-align: center;
       margin: 0 auto;
   }

By using 'margin: 0 auto', your div block will be centered, allowing you to adjust the width as needed.

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

Collapsed Grid System

Is it possible to create a CSS grid system that meets the following requirements: The grid should have arbitrary height (with consistent width) and when a grid overflows, it should stack vertically underneath the preceding grid, regardless of other grid ...

Prevent HTML Link from being accessed again after being clicked

My goal is to prevent a link from submitting my form multiple times when clicked. I need this to avoid duplicate requests being sent by the same user. Below is the code I've tried, but unfortunately, it does not seem to be effective. <a id="submit ...

How to Move an Element Using HTML and jQuery: Removing with detach() and Reinsert

In my current website setup, I have implemented a feature where clicking on a div triggers the appearance of a sub menu below the clicked div. Now, I am attempting to detach() this sub menu, insert it after the div that was clicked, and adjust its position ...

Modifying webpage design using JavaScript for styling

Is there a way to change the css style(defined in the page source) dynamically with Java? I know it is possible to do it with JavaScript. If there isn't, are there other situations where JavaScript is the only choice developing a web app? ...

Alter the CSS display based on the user's userAgent if they are using an iPhone and window.navigator.standalone is set to true

Looking to create a unique webAPP with different content displays based on how it is accessed. If the user opens the webAPP through their Safari browser Or if they open the webAPP from a webclip on their home screen The detection is functioning, as conf ...

What is the best way to incorporate Tradingview's JavaScript into the render function of a React Typescript

I'm trying to incorporate some widgets into my Typescript React component. Here is the embed code export default class App extends React.Component { render(): ReactNode { return ( <div> Chart test <div className= ...

I am unable to show a list in a sequential manner on a Flask webpage

Here is the function I implemented to return the list line by line: def listing(table): x=0 tab=[] for item in range(0,len(table)): x+=1 result= f'{x}- {table[item]}' tab.append(result) final = '&bsol ...

Are JQuery functions affected when navigating between pages in smart-tables?

Apologies if this question has been answered before or seems obvious. I couldn't find a solution after searching, and as someone new to web development, I might be going in circles here. Issue: I've integrated the smart-table extension () into ...

Is it possible to execute a PHP script within a .css file and ensure it functions correctly?

Recently, I've been making some changes to the .css file in order to get my PHP codes to work. However, when I insert them as usual, they appear as regular text. I'm curious to find out if it's possible to execute a PHP file within a .css fi ...

Issues with onClick events not triggering on transformed CSS3 elements

//My mind was completely tangled up. Everything is functioning properly, this question is inaccurate and outdated When I rotate an Element on the Y-axis and attempt to click on it, which has a bound eventListener (onClick), the event does not trigger (hov ...

Achieving perfect alignment for images within a Bootstrap 4 carousel - both vertically and horizontally

Utilizing Bootstrap 4 carousel, I am attempting to center an image both vertically and horizontally. Below is my code along with the styling that I have applied: <div id="myCarousel" class="carousel slide" data-ride="carousel"> <ul class="car ...

The full extent of the background color is not reaching 100% of the height

My content wrapper has a height set to 100%, but the issue is that the background color doesn't fully extend across all content. Here are some images and my code for reference. Any assistance would be greatly appreciated! You can see the white space a ...

Attempting to adjust the width upon hovering with CSS

I have attempted this previously and cannot figure out why it is not functioning properly. I am attempting to do the following: http://jsfiddle.net/geometron/u3M6r/1/ <ul> <li><a href="content1.html"> Demo 1 </a></li> ...

Issue with adding Valid/Invalid Classes to prefilled text fields is not being resolved

While utilizing the MaterializeCSS framework, I encountered an issue with dynamically populating text inputs. The problem arises when the valid and invalid css classes do not get applied to my fields until they are focused. Even after calling M.updateText ...

Hover Effect Not Functioning Properly

I am attempting to create a vertical wobble effect on my anchor tag, inspired by an example found at the following link: This is the code I have implemented: .hvr-wobble-vertical { display: inline-block; vertical-align: middle; -w ...

Alter the color of a single character using JQuery, all while keeping the HTML tags unchanged

I'm currently working on iterating through the DOM using JQuery in order to change the color of every occurrence of the letter m. Here is what I have so far: $(document).ready(function(){ var m = "<span style='color: red;'>m</span& ...

Looking for help organizing a navigation bar?

I recently embarked on the journey of creating my own website and I am in need of assistance from individuals who possess expertise in CSS and HTML. The specific challenge I'm currently facing involves aligning the navbar elements properly. I aim to p ...

Maintain the button's placement

Hey there, I'm a newcomer to the world of development. Currently, I am working on a project that involves a button within a flex container setup. Here is the code snippet for the button: <div class="flex-item flex-item-button" > ...

What is the best way to gradually transform a continuously shifting text color into a single, consistent hue?

Hey there, wonderful people of StackOverflow! I am absolutely stumped and cannot figure out how to smoothly transition this color-changing text from its current state into a different solid color when the submit button is clicked. Is there a skilled indiv ...

Exploring the Iteration of Nested Dictionaries and Lists in Django Templates

Currently, I am working on integrating Google spreadsheets into Django. In my project, I have defined two models: class Workbooks(models.Model): name=models.CharField(max_length=100) class Sheets(models.Model): ...