After positioning is a technique used to strategically place elements on

During the hours of 11:30 to 16:00, I tuned in to a video on frontend development. This period of time led me to explore different design elements and coding techniques.

    <div class="title-wrapper">
        <h2 class="title title--purple"><span>Live Auctions</span></h2>
    </div>
    .title {
        font-family: 'Oxanium',
        font-weight: 700;
        font-size: 64px;
        line-height: 130px;
        color: #F5FBF2;
        position: relative;

        &:after {
          content: '';
          position: absolute;
          top: 50%;
          left: 0;
          transform: translateY(-50%) translateX(-40%);
          background: #8613A5;
          width: 110px;
          height: 110px;
          border-radius: 50%;           
        }

        span {
          text-align: center;
          position: relative;
          z-index: 2;   
        }
    }

    .title-wrapper {
        display: flex;
        justify-content: center;
    }

This exploration resulted in an image capture showcasing the Live Auctions title.

Click here to view the screenshot.

How can CSS properties such as "top: 50%;", "left: 0;", and "transform: translateY(-50%) translateX(-40%);" be used creatively to emphasize specific elements like the letter L with a lilac circle?

I am looking for assistance in implementing this layout effectively. Can someone lend a hand?

Answer №1

  • At first, the top left corner of the circle aligns with the top left corner of the highlighted text block. Keep in mind that using line-height: 130px significantly increases the height of the block compared to the text.

.title {
  font-family: 'Oxanium', font-weight: 700;
  font-size: 64px;
  line-height: 130px;
  position: relative;
  background-color: yellow;
  &:after {
    content: '';
    position: absolute;
    /* top: 50%; */
    left: 0;
    /* transform: translateY(-50%) translateX(-40%); */
    background: #8613A5;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    opacity: 0.5;
  }
  span {
    text-align: center;
    position: relative;
    z-index: 2;
  }
}

.title-wrapper {
  display: flex;
  justify-content: center;
}
<div class="title-wrapper">
  <h2 class="title title--purple"><span>Live Auctions</span></h2>
</div>

  • Once top: 50% is applied (relative to the block's height), the circle shifts vertically so its upper point intersects with the middle of the text block.

.title {
  font-family: 'Oxanium', font-weight: 700;
  font-size: 64px;
  line-height: 130px;
  position: relative;
  background-color: yellow;
  &:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    /* transform: translateY(-50%) translateX(-40%); */
    background: #8613A5;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    opacity: 0.5;
  }
  span {
    text-align: center;
    position: relative;
    z-index: 2;
  }
}

.title-wrapper {
  display: flex;
  justify-content: center;
}
<div class="title-wrapper">
  <h2 class="title title--purple"><span>Live Auctions</span></h2>
</div>

  • Applying transform: translateY(-50%) (relative to the circle's height) moves the circle vertically so its center aligns with the previous upper point.
  • translateX(-40%) shifts the circle horizontally to the left by 40% of its width.

Answer №2

There seems to be a syntax error in the title class of your code. I have included the code below for us to visually inspect the output using the run snippet feature. What exactly is your goal with this code?

body {
  background-color: gray;
  font-size: 14px;
  font-family: Arial;
}
.title {
     font-family: 'Oxanium';
     font-weight: 700;
     font-size: 64px;
     line-height: 130px;
     color: #f5fbf2;
     position: relative;
}
 .title:after {
     content: '';
     position: absolute;
     top: 50%;
     left: 0;
     transform: translateY(-50%) translateX(-40%);
     background: #8613a5;
     width: 110px;
     height: 110px;
     border-radius: 50%;
}
 .title span {
     text-align: center;
     position: relative;
     z-index: 2;
}
 .title-wrapper {
     display: flex;
     justify-content: center;
}
 
 <div class="title-wrapper">
        <h2 class="title title--purple"><span>Live Auctions</span></h2>
    </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

the optimal approach to determine character spacing in SCSS

I am currently working on an input field that is styled using CSS for digit entry. However, I am facing issues with the variations in character or digit width, causing them to misplace upon rendering. My project involves VUE and Laravel development, and I ...

Is there a way to prevent an inline SVG from appearing at a random height without specifying its height or the height of its parent element?

Displayed here is a simplified Bootstrap 3 layout. The middle column in the row features an inline SVG that transitions from a blue box to a green box. I've opted for styling SVG with browser CSS because I find it interesting! Additionally, this appr ...

Add a <span> element to the header element in the CSS using jQuery

Struggling to add this unique element after a specific css-class on my website powered by Wordpress: <span class="blink">_</span> I'm unable to alter the file structure, but I have the liberty to utilize CSS and jQuery. The chunk of code ...

What steps can I take to stop my Details element from moving a nearby Div?

Within this setup, there is a div containing Details and Summaries to the left. Upon expanding the details, the text enlarges and the container moves, causing the image in the right div to shift downward. Is there a way to prevent this from happening? I ...

Unique design for circular checkbox inside Bootstrap popover

I am experimenting with a custom round checkbox .round { position: relative; } .round label { background-color: #fff; border: 1px solid #ccc; border-radius: 50%; cursor: pointer; height: 28px; left: 0; position: absolute; top: 0; wi ...

Encountering an error of "undefined is not iterable, cannot read property Symbol(Symbol.iterator)"

While learning React through coding, I encountered an error (Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator)). I am unsure where the problem lies. Any suggestions? When utilizing useEffect to activate setFiltere ...

Transform a dropdown menu into an inverted footer

I stumbled upon a unique dropdown menu design that I want to tweak and reverse, making it an innovative "dropup" menu that opens from the bottom to the top. Currently, this is what I have: HTML <div class="get-started"> <a href="#" id="get-s ...

Add a new division to a component when a specific event handler is triggered by another component using React and the reduce method

Currently, I am developing an interactive drag-and-drop application using React and Redux. My goal is to insert a new div element into a container when the ondragstart event handler is triggered by a component. The component responsible for the dragging o ...

unexpected issue when trying to append a child element after creating its innerHTML

Upon executing this script, I expect to see the initially empty div with id="checkboxes" transformed into: <div id="checkboxes"> <label><input type="checkbox">option1</label> <label><input type="checkbox">opt ...

Using a JavaScript if statement to check the height of a specific HTML element

I have been struggling to figure out how to insert an if-else statement in JavaScript that references data about an HTML element. My objective is to create an "onclick" function that enlarges an image with a 200ms delay and another function that returns th ...

I am unable to view the input appearing inside the input box on my React/HTML application

I have been developing a React app for building portfolios, but I am facing an issue where I cannot see any text that I type into my input boxes. Can someone please help me troubleshoot this issue? Any assistance would be greatly appreciated. I have made ...

Leveraging the Scroll feature in Bootstrap for smooth scrolling

Seeking assistance with implementing scroll in Bootstrap 5 on my child component (ProductList.vue). Can anyone guide me on how to integrate the code? I have been searching for a solution without success. Below is the Bootstrap 5 code on the child component ...

Center align the text inside a table cell of a span that is floated to the right and has a varying

Struggling to align a span vertically in the middle with a different font size than its table cell. The goal is to have the following layout: | | | Measurement (font-size: 100%) unit (font- ...

The margin property in jQuery does not seem to be functioning properly when trying to send

Within the view page, there is jQuery code that sets a margin on a div. Below is the code: <script type='text/javascript'> $('#someID').css('margin-left', '10px'); </script> This code functions proper ...

Is there a way to customize the default settings for a blueprint’s menu item?

https://i.sstatic.net/aNeJY.jpg In my react project, I implemented the Menu using MenuItem from '@blueprintjs/core'. The issue I encountered is that when hovering over a Menu item with children, they open from the right side. Is there a way to m ...

Issues with web display on Android devices

My website is having display issues specifically on Samsung and Motorola devices, even when using different browsers. It seems that the area using transform CSS is breaking apart. You can view my website at I've tried several fixes but nothing seems ...

Having trouble retrieving information from the Label text input field

In the current rating system code, I am able to display text from a script on a label but unable to store it in the database. When attempting to save it in the database, only the id=@a1 is showing zero while all other values are successfully stored. Aspx ...

Encoding URLs in C#

Similar Question: How can I replace spaces with %20 in C#? I'm searching for a URL encoding solution in C#. While I am aware of Server.UrlEncode, I believe it encodes spaces as a + symbol. I vaguely recall another method that encodes spaces as %2 ...

Transferring items between containers with stylish animations in AngularJS

Two of my divs have different contents, with one initially empty and the other filled with items. By clicking on an item in the first list, I want to transfer it over to the second list through a visual animation that implies movement from right to left. W ...

Unexplained failure of Angular2's FileReader component

Currently, I have set up the following code in Angular 2 to read image files. The method involves using an input element to prompt the user to select a file, and then triggering the addThumbnail function once a file is chosen. The click event on the input ...