The hyperlink intersects with the text block when it comes to responsive layout

I am struggling with adjusting the position of a link so that it doesn't overlap with the paragraph. I've tried using top and margin-top properties, but the link just won't budge. Additionally, I have a horizontal line (hr) below the link that I also want to move lower, but it remains static. I'm unsure how to resolve these issues. Please review the code snippet below:

HTML:

<p class="teaser">There is ongoing discussion about the future of EU citizens in the UK, whether they will be allowed to remain on the island. This raises questions about British citizens living in the EU, as well as what will happen to British citizens traveling to Europe. Will UK citizens need visas to visit Spain or other destinations in Europe? There is much speculation surrounding the future of EU citizens li</p>
<figure>
 <a class="back" href="articles.html">Back to articles</a>
</figure>

<hr class="bottom-line">

CSS (desktop):

.teaser {
    text-align: justify;
    margin: auto;
    width: 50%;
    line-height: 1.5;
    position: relative;
    top: 20px;
    text-align: justify;
    text-indent: 2%;
    line-height: 2;
    font-family: "Times New Roman", Times, Serif;
    font-size: 20px;
}
.back {
    text-align: center;
    top: 5px;
    text-decoration: none;
    font-family: "Times New Roman", Times, Serif;
    font-size: 25px;
    color: black;
}
.back:hover {
    color: #2347b2;
}
.bottom-line {
    text-align: center;
    width: 50%
}

CSS (responsive):

.teaser {
    width: 100%;
    margin: auto;
    top: 45px;
}   
.figure back {
    margin: auto;
}
.bottom-line {
    width: 100%;
    margin: auto;
}

Answer №1

It seems that the issue lies in forgetting to add padding to the bottom.

To resolve this, include the following code in the .teaser section:

padding-bottom: 30px;

This adjustment should address the problem you are experiencing.

Additionally, please note that there is an error in your .figure section. Update it as follows:

figure .back { insert code here }

Answer №2

There are a few issues that need to be addressed here. The use of "<figure>" as a class instead of an element is incorrect, and it should not begin with a ".". Additionally, this error is present in your "responsive" CSS file as well. To resolve this issue, you will need to implement media queries to distinguish between the two.

It is also important to remove the position:relative property, as this is likely the cause of the problem you are experiencing.

Answer №3

The reason for this issue is the use of position:relative; on the .teaser class. Removing it will resolve the problem.

To gain a better understanding, I recommend learning more about the position Property.

Your CSS file contains some redundant attributes such as text-align and line-height. Consider running a css linter to identify and correct these issues.

Answer №4

Exclude the position:relative property from the .teaser class

.teaser {
    text-align:justify;
    margin:auto;
    width: 50%;
    line-height:1.5;
    top: 20px;
    text-align:justify;
    text-indent:2%;
    line-height: 2;
    font-family: "Times New Roman", Times, Serif;
    font-size: 20px;
    }
    .back {
    text-align:center;
    top:5px;
    text-decoration: none;
    font-family: "Times New Roman", Times, Serif;
    font-size:25px;
    color: black;
    }
    .back:hover {
    color: #2347b2;
    }
    .bottom-line {
    text-align:center;
    width:50%
    }
    .teaser {
        width: 100%;
    margin:auto;
    top:45px;
    }
    .figure .back {
    margin: auto;
    }
    .bottom-line {
    width:100%;
    margin:auto;
    }
<p class="teaser">There are lots of discussions happening around the future of EU citizens living in the UK, whether they will or will not be able to stay in 
</p>
    <figure>
         <a class="back" href="articles.html">Back to articles</a>
    </figure>
<hr class="bottom-line">

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

When transitioning from another page, the header will cover a portion of the section

I am facing a specific issue that I need help with. My goal is to have the navigation bar link to different sections of a single page when clicked. For example, clicking on "Contact" should take the user to the contact section, and then if they click on "A ...

Safely render user-generated HTML content within a React application to prevent cross-site scripting vulnerabilities

A unique situation has arisen in our React app where a user inputs a string that is displayed to other users. The challenge lies in searching for specific characters within the string and replacing them with HTML elements. For example, transforming the wor ...

Is it possible to have several flexboxes with a margin-right applied to each one except for the last one in the row,

Take a look at the image below: The setup currently displayed is in the top-left corner. If I were to add more red boxes, they would wrap to the next line with a 10px right margin on the last box of the first row. My inquiry: Is it possible to achieve t ...

How can I toggle a textbox's enabled and disabled state in Angular using a checkbox?

I am currently working with Angular and TypeScript and I am attempting to implement a feature that enables or disables a textbox based on the status of a checkbox. app.component.html <input type="checkbox" value="true" (click)=" ...

Integrating HTTP JSON responses into HTML using Ionic 2, Angular 2, TypeScript, and PHP: A comprehensive guide

Currently in the midst of developing my first Ionic 2 app, however, my understanding of typescript is still limited.. I aim to execute the authenticate() method within my constructor and then to: Retrieve the entire JSON response into the textarea and/o ...

Load Bootstrap CSS file externally on a website dynamically

Although my knowledge of JavaScript is limited, I am the recipient of a small web application from a friend that is being utilized by multiple companies. As each company requires specific modifications in the appearance and CSS of certain webpages, it can ...

Adjust the child element's value by referencing the parent class name

I need to update the content of child elements within an HTML file based on the class name of their parent element, using JavaScript. While I have successfully achieved this for static values by creating a TreeWalker for text nodes, doing the same for dyn ...

There seems to be an issue with the visibility of the b-button within the b-table component in

I'm new to Vue Js and I'm having trouble with my b-button not displaying in my table. I can't figure out why. Below is my HTML code: <div id="listlocales"> <div class="overflow-auto"> ...

Is it possible to automatically refresh a webpage with the same URL when accessed on the same server?

Is there a way to trigger a URL page refresh using JS code located on the same server? For example, I have a URL page open on multiple devices connected to the same server. How can I ensure that when I click 'Update,' the page refreshes simultan ...

ways to update a VueJS element's class multiple times

Looking to implement a vanilla JavaScript function in Vue.js For example: https://codesandbox.io/s/xjk3xqnprw This is the functionality I aim to achieve in Vue.js. Although my Vue component loads perfectly, it lacks animation. Here's my Vue compone ...

Enhance your web design skills by customizing Bootstrap5 framework styles using the @layer feature

Here is the HTML code I am working with: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name=& ...

Dropdown feature in the side navigation bar

Is it possible to create a drop-down section in a navigation bar using HTML/CSS/JS? For example, clicking on 'products' would reveal a list of products that disappears when clicked again. If this is achievable, how can it be done? I am currently ...

What could be causing this excessive lag?

I've been developing a new website, but the "buttons" I'm using seem to be causing significant lag. I need help resolving this issue. You can view the website here: The problematic code snippet is shown below: <td> <a href="templi ...

What steps can be taken to resolve the error message "AttributeError: 'WebElement' object does not have the attribute 'find_element_class_name'?"

try: main = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "main")) ) articles = main.find_elements_by_tag_name("article") for article in articles: header = article.find_element_c ...

Encountered an error while trying to load resource: server returned a 404 status code (NOT FOUND) when using flask

I am facing an issue with a web application I am currently developing. I am using Python Flask on the server side, and every time I try to run the Python app, I encounter a "Failed to load the resource, 404 page not found" error. Below is the structure of ...

Troubleshooting Problem with Bootstrap CSS Menu Box Format

I'm having trouble creating a simple menu for my Bootstrap site. What I want to achieve is something like this: https://i.sstatic.net/abZXC.png This is what I have accomplished so far: https://i.sstatic.net/JFVC2.png I've attempted to write th ...

Encountering an issue: Integrating JSON data into HTML using Angular.JS!

Having trouble transferring JSON data to HTML using Angular.JS for a programming course. The author doesn't seem to have this issue, can anyone provide some assistance? I've correctly linked Angular and added the app, but it's not working a ...

The presentation of an HTML table varies between Gmail and web browsers

<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" height="131" border="0" cellspacing="0" cellpadding="0"> <tr> <td wid ...

The problem with column width in Datatable persists even after refreshing the row data

Utilizing datatable to generate the table showcased below: https://i.sstatic.net/N795U.png Satisfied with the outcome as each column's width is automatically calculated, keeping one line per row for a clean look. The API generates the table above us ...

Field where tags are generated by user input

I want to incorporate an input field on my website where users can list their skills. These skills should be displayed individually as separate elements on the front end of the site. The desired format for users to input their skills is as follows: skil ...