Is it possible for a CSS menu with border to slide off the screen?

https://i.sstatic.net/bBbkU.png

How can I create a CSS menu with borders that do not overflow off the page when using margin:0;

I am trying to add a border to my CSS links without them overflowing on top of the page. I have imported my custom.css file into index.php. I would like to keep body{margin:0;background-color:#ddd;color:#0000ff;}

html{
font-family:sans-serif;  
font-size: 14px;
}

body{
margin:0;
background-color:#ddd;
color:#0000ff;
 }

a{
font-family:sans-serif;
font-size: 18px;
background-color:#000;
color:#fff;
border-style: solid;
border-color: red;
padding: 5px;
border-width: 5px;

}

a:hover {
font-family:sans-serif;
 color:#83F52C;

Answer №1

To modify the appearance of the links, consider adjusting the display property to inline-block. This will alter how the links wrap, ensuring each link wraps as a whole rather than midway through. Given that a colored border on a partially wrapped link may appear odd, this change is likely desired.

html {
  font-family: sans-serif;
  font-size: 14px;
}
body {
  margin: 0;
  background-color: #ddd;
  color: #0000ff;
}

a {
  display: inline-block;
  font-family: sans-serif;
  font-size: 18px;
  background-color: #000;
  color: #fff;
  border-style: solid;
  border-color: red;
  padding: 5px 5px 5px 5px;
  border-width: 5px 5px 5px 5px;
}
a:hover {
  font-family: sans-serif;
  color: #83F52C;
<head>
  <title>Zulu.ieo</title>
</head>

<body>
  <a>Here is a link</a>
  <a>A veeeeeeeeeeery long link</a>
  <a>Another link</a>
</body>

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

Issue with animated cursor function not activating when used with anchor links

I've spent hours searching for a solution but I can't seem to find one. I'm attempting to modify the codepen found at https://codepen.io/Nharox/pen/akgEQm to incorporate images and links, however, two issues are arising. The first issue is t ...

Ways to verify when leaving the webpage

After spending an excessive amount of time searching for this information, I finally figured it out. So here you have it, I'm sharing the steps to create a custom "ARE YOU SURE YOU WANT TO LEAVE THIS PAGE?" dialog. ...

Retrieving sub-menu page titles using PHP and Wordpress

My PHP code block currently assigns different styles to headings based on the main page title, but I am facing an issue with sub-menu items. The code works for the main navigation pages but doesn't apply the color profiles to sub-page style elements. ...

Best practices for storing a HTML file in MongoDB

It seems that one of the benefits of using a document-oriented database such as MongoDB is its ability to store unstructured data effectively. For instance, when dealing with multiple HTML files, is it advantageous to have the entire content stored as a ...

Identify the currently active subitem within the item-active class in a PHP carousel slider

I am working on creating an image carousel slider with 4 items and 4 slides each. These images will act as radio buttons, and I want to highlight the slide corresponding to the selected radio button. So, when the carousel loads, the selected slide should b ...

Show a concealed vertical menu on mobile using CSS

I successfully implemented a drop-up footer on my website: $('#drop-up-open').click(function() { $('#drop-up #drop-upDashboard').slideToggle({ direction: "up" }, 300); $(this).toggleClass('drop-upClose'); }); // e ...

Mastering Yii2: Implementing Javascript Functions such as onchange() in a View

One of the elements in my project is a checkbox: <div class="checkbox"> <label> <?= Html::checkbox('chocolate', false) ?> Chocolate </label> </div> In addition to that, I also have a span ta ...

Mobile-style menu with full desktop height

I am currently working on developing my first custom WordPress theme from scratch. My goal is to design a mobile-style menu that can also be displayed on desktop screens. To achieve this, I have used jQuery to implement the sliding effect. You can view a ...

What is the best way to emphasize parent categories in a product table using Woocommerce?

I have a table of products used for filtering categories. My goal is to display only the parent categories in bold font. When searching results like in this link (e.g. https://demo.motorocker.gr/?swoof=1&antalaktika=scooter), we want the parent categor ...

What causes the Footer to appear as a floating element in Tailwind CSS?

I've implemented the tailwind CSS footer into my NextJS project to display fetched data. However, I encountered an issue where the footer only floats when there is less data present. To address this problem, I created a separate footer file within my ...

Maintain line breaks in the scanner input within an HTML element

Currently, I am utilizing a Zebra DS9908 scanner to scan a barcode and transfer the data onto an HTML page. However, I am encountering an issue with preserving all input characters. Despite attempting both a <div> and <textarea>, the line feed ...

triggering phpmailer to send an email upon data deletion

My current system includes a form that successfully adds a user to a MySQL database table and also sends an email with the new information to a specified address. However, I am now facing an issue with implementing a form that is meant for deleting record ...

Display "Temporary Text" in an HTML drop-down list if no selection is made

Is there a way to ensure that the placeholder in an existing select element always remains visible? I noticed that when I select an option and then go back to the blank item, the placeholder disappears. How can I make sure it is always displayed when no ...

The chosen options are not appearing. Could this be a problem related to AngularJS?

I am working on setting up a dropdown menu in HTML that includes only the AngularJS tag. This dropdown menu will be used to populate another AngularJS dropdown menu. Below is the code for the first dropdown menu: <select class="form-control" ng-model=" ...

Ways to stop two JavaScript files from running at the same time

After combining two JavaScript files, I am facing some issues. The first file handles validation while the second one has an ajax plugin for form submission after validation. When I include these files in the header section, they both run simultaneously. H ...

Is there a way to UPDATE a div without having to RELOAD the entire page in it?

SOLVED -SORT OF--- After much frustration, I finally found a solution to my problem. By adding window.location.reload(); in my code where the submit button is, I was able to close the div successfully. // Collapse Panel on submit $("div#panel").on(' ...

Exploring search capabilities within D3 graph nodes

After creating a JSON file with four tiers and utilizing D3.js's collapsing box format to visualize it (source: https://bl.ocks.org/swayvil/b86f8d4941bdfcbfff8f69619cd2f460), I've run into an issue. The problem stems from the sheer size of the J ...

"The Toggle Switch/checkbox on Proto.io is stuck and not toggling as

I'm currently struggling to make a toggle switch work on my webpage. Despite trying different approaches such as removing data or not applying it to the input element, the toggle still refuses to function properly. The data-field attribute is supposed ...

The v-autocomplete feature in vuetify doesn't allow for editing the text input after an option has been selected

Link to code on CodePen: CodePen Link When you visit the provided page and enter "joe" into the search box, choose one of the two Joes that appear. Try to then select text in the search box or use backspace to delete only the last character. You will no ...

Adjusting Header Image to Match Screen Dimensions

I am currently struggling to make the header image on my new WordPress website resize dynamically based on the device I am using to view it. Despite trying various suggestions from different sources, I have not been able to achieve the desired result. The ...