"Struggling to horizontally center a div with a fixed width in CSS - what am I

Whenever I try to use it on my browser, the content shifts to the left and I can't seem to center it using text-align or flexbox. The issue gets resolved when I remove the width property, but I really need it to have that paragraph-style look I'm aiming for.

.pragraph  {
    position: absolute;
    width: 1300px;
    height: 182px;
    left: 30px;
    top: 699px;
    line-height: 65px;
    text-align: center;
    
    
}
.pragraph p {
    position: absolute;
    font-size: 40px;
    font-family: 'Peddana', serif;
    text-align: center;
    width: 100%;
    
    
}
<div class="pragraph">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sapien diam, eleifend eu fringilla auctor, laoreet et elit. Phasellus efficitur posuere dui vitae laoreet. Phasellus</p>
</div>

Answer №1

.content    {
    position: fixed;
    width: 100%;
    height: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: lightgrey;
    text-align: center;
    padding: 20px;
    
}
.content p {
   
    font-size: 24px;
    font-family: 'Arial', sans-serif;
    color: black;
    text-align: center;
    
    
}
<div class="content">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget diam quis neque molestie pharetra vel ac eros</p>
</div>

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

Position a div at the bottom of another div using Bootstrap

I'm facing an issue with trying to position an inner div at the bottom of an outer div using bootstrap classes. I have attempted various methods in both bootstrap and regular CSS, such as vertical-align: bottom; and setting position to absolute, but n ...

Arrange three images and three text lists in a horizontal layout with responsiveness

Struggling with a HTML/CSS challenge here! I'm attempting to vertically align 3 images and text in the pattern of image, text, image, text, image, text. Everything looks great on my 13" MacBook, but once I start resizing the window, chaos ensues. Any ...

Utilize Wordpress TinyMCE to apply the underline decoration using the "U" tag instead of the style

Is there a way to modify the function of the button in the WordPress content textarea of TinyMCE? Specifically, I am referring to the "u" button for underline formatting. <span style="text-decoration-line: underline;">text underlined</span> I ...

Is there a method to display text on the screen after a countdown has finished?

I am looking for a way to display some text or an image of a cake on the screen once this countdown reaches zero. It's a countdown leading up to my birthday, and I really want it to have that special touch at the end. However, I've been strugglin ...

List that dynamically changes in HTML email template

I'm currently working on an email template using HTML, and I've run into a roadblock while trying to create a list based on Java code data. The challenge is that the length of the list varies each time. Here's what I tried: <span st ...

At what point will the browser display changes made to css using jQuery?

When I run my JavaScript code in Firebug, it looks like this: tr=$(this).parent('tr'); tr.find('.img-delete').css('display','block'); However, I am unable to see the change reflected on the browser. Is there a wa ...

The event.pageY position consistently reflects the laptop screen size rather than the exact position where the click occurred

My webpage is scrollable, but the event.pageY position always corresponds to my screen size. Even when scrolling down and clicking near the top of the screen, it registers as 50px. I am currently utilizing event.pageY While this functions correctly on a ...

Ensure the placeholder remains front and center, growing in size as it moves vertically

.inpsearch{ border:2px solid #bbb; border-radius:14px; height:29px; padding:0 9px; } .inpsearch::-webkit-input-placeholder { color: #ccc; font-family:arial; font-size:20px; } <input type='search' class='inpsea ...

Creating a page turn effect during the loading of a page within an iframe

Is there a way to create a page turn effect similar to reading a book for an iframe that is loading dynamic content? Any suggestions would be greatly appreciated. Link: ...

Vue Quasar Drawer Layout with Bottom Bar

Struggling to implement a footer in my q-drawer. Below is the template and component code I am currently using: <template> <q-layout view="hHh lpR fFf"> <q-header elevated> <q-toolbar> <q-btn flat de ...

Discovering the chosen value from an asp.net radio button control based on its class can be accomplished using Jquery

Currently, I am working with a radio button control that is defined like this: <asp:RadioButtonList ID="rbQ2" CellSpacing="10" runat="server" class="rbQ2" CssClass="radioButtonList" RepeatDirection="Horizontal" RepeatLayout="Table" onclick="javascript: ...

Ways to update list item text with jQuery

I am attempting to create a button that can replace the content of a list item. Although I have looked at other solutions, I keep encountering this error message: Uncaught TypeError: Object li#element2 has no method 'replaceWith' I have experime ...

Disappearance of logo div causes video to vanish

Hey there fellow coders! I'm facing a little issue. I'm attempting to replicate my webpage on another page, but every time I try to remove the logo, the video disappears as well. It's quite puzzling. I have the code in place, but it seems l ...

Customizing the active link color in Bootstrap dropdown menus

Is there a way to customize the color and background of an active link in a boostrap's dropdown menu? Despite trying to override bootstrap's @dropdownLinkColorActive and @dropdownLinkBackgroundActive variables, the changes don't seem to tak ...

Fetching User Details Including Cart Content Upon User Login

After successfully creating my e-commerce application, I have managed to implement API registration and login functionalities which are working perfectly in terms of requesting and receiving responses. Additionally, I have integrated APIs for various produ ...

Unusual outcome observed when inputting a random number into HTML using JavaScript

In my HTML file, I am trying to input a number within 50% of a target level into the "Attribute" field. Here is the code: <!DOCTYPE html> <html> <body> <input type = "number" name = "playerLevel" onchan ...

jQuery's :last selector allows you to target the last

I need assistance with my jQuery code $('#share_module:last').css("background-color","red"); Unfortunately, it is only affecting the first #share_module Here is an example of the HTML structure: <div id = "share_module" class = "id of the ...

Why does one of the two similar javascript functions work while the other one fails to execute?

As a new Javascript learner, I am struggling to make some basic code work. I managed to successfully test a snippet that changes text color from blue to red to ensure that Javascript is functioning on the page. However, my second code attempt aims to togg ...

Having trouble with custom padding for b-sidebar in VueJS?

I am struggling with adding padding to the sidebar using bootstrap-vue. When I attempt to add padding in the browser devtools, it works perfectly fine. However, when trying to implement the same code, it doesn't reflect on the actual webpage. I tried ...

Python web scraping with BeautifulSoup to gather information

After searching on zillow, I aim to extract all items from the unordered list and target a specific class: "StyledPropertyCardDataWrapper-c11n-8-84-3__sc-1omp4c3-0 bKpguY property-card-data" This class contains information such as price, address ...