How to stop font-family and letter spacing from affecting the margin of div and ul elements in CSS

I'm facing a challenge with aligning a rotated div and an unordered list in a container. Adjusting the margin of either element does the trick, but changing font-family or letter-spacing globally affects the spacing between the two.

Check out this JSFiddle link

Open the fiddle and inspect the letter-spacing property on * to visually understand the issue.

    #container {
        z-index: 2147483645;
        height: 400px;
        width: 400px;
        background-color: grey;
        display: inline-block;
        position: fixed;
    }
    #tab {
        background-color: #9F8F6C;
        display: inline-block;
        vertical-align: top;
        height: 100%;
        width: 40px;
        padding: 0;
        margin: 0;
    }
    #tab a {
        position: fixed;
        width: 400px;
        -webkit-transform: rotate(-90deg);
        -moz-transform: rotate(-90deg);
        -ms-transform: rotate(-90deg);
        -o-transform: rotate(-90deg);
        transform: rotate(-90deg) translateX(-100%);
        transform-origin:left top;

        font-size: 18px;
        cursor: pointer;
        text-align: center;
        color: #F5F5F5;
        text-decoration: none;
        padding: 0;
        margin: 0;
    }
    #my-list {
        background-color:rgba(255,255,255,0.5);
        display: inline-block;
        vertical-align: top;
        height: 100%;
        width: 65px;
        padding: 0;
        margin: 0;
    }
    * {
        letter-spacing: 2px;
    }
<div id='container'>
    <div id='tab'>
        <a id='tab-text'>hellloooo</a>
    </div>
    <ul id='my-list'>

    </ul>
</div>

Answer №1

It seems like all you need to do is update the letter-spacing property from * to tab.

For the sake of demonstration, I have switched out your ID's for classes as IDs must be unique within the code.

Below is an example snippet:

#container {
  z-index: 2147483645;
  height: 400px;
  width: 400px;
  background-color: grey;
  display: inline-block;
  position: fixed;
}
.tab {
  background-color: #9F8F6C;
  display: inline-block;
  vertical-align: top;
  height: 100%;
  width: 40px;
  padding: 0;
  margin: 0;
  /*letter-spacing:2px  APPLY HERE */
}
.tab a {
  position: fixed;
  width: 400px;
  -webkit-transform: rotate(-90deg);
  -moz-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);
  transform: rotate(-90deg) translateX(-100%);
  transform-origin: left top;
  font-size: 18px;
  cursor: pointer;
  text-align: center;
  color: #F5F5F5;
  text-decoration: none;
  padding: 0;
  margin: 0;
}
#my-list {
  background-color: rgba(255, 255, 255, 0.5);
  display: inline-block;
  vertical-align: top;
  height: 100%;
  width: 65px;
  padding: 0;
  margin: 0;
}
/*DEMO PURPOSES*/

.letter-spacing {
  letter-spacing: 2px 
}
<div id='container'>
  <div class='tab letter-spacing'>
    <a class='tab-text'>hellloooo</a>
  </div>
  <div class='tab'>
    <a class='tab-text'>hellloooo</a>
  </div>
  <ul id='my-list'>

  </ul>
</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

JavaScript code that triggers when a checkbox is not selected

I'm attempting to dynamically add an input field when a checkbox is clicked, with the intention of having the checkbox already checked by default. However, I am encountering an issue where the checkbox remains unchecked even after the input field is d ...

Images cannot be uploaded to the login page

Here is the code for the login.aspx page: <%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="DoubleEntryForm.Account.Login" %> <asp:Content ID="HeaderContent" runat="s ...

Storing personalized HTML content in a database for individual users: A step-by-step guide

I have a JavaScript code snippet similar to this fiddle: http://jsfiddle.net/nj4N4/7/ On my webpage, it displays like this: image. When you click on the "add a year" button, a table resembling year2 appears above the previous year. Now, I'm looking ...

Struggling with Implementing Modals in Bootstrap 3.3.7

I've been encountering an issue with modal functionality. In order to troubleshoot my own modals, I decided to replicate the modal example code from Bootstrap's website into a new HTML file. Despite linking to the CDN, the modal does not functio ...

What is the process for programmatically aligning two cards side by side using Material UI in React after retrieving data from an API?

I am currently working with data from an API that I need to display in the format of cards, arranged side by side. To achieve this, I have been using an array and passing the data to components programmatically. You can see the output image and my code bel ...

Create a pagination system in CodeIgniter for displaying data

Having trouble implementing paging in the search functionality of my result table. I want to display just 10 rows but can't get it to work properly. I tried reading about Pagination on https://codeigniter.com/, but I'm still struggling to unders ...

Creating a Select component in React without relying on the Material-UI library involves customizing a dropdown

Is there a way to achieve a material UI style Select component without using the material UI library in my project? I'm interested in moving the label to the top left corner when the Select is focused. export default function App({...props}) { retu ...

What is the best way to retrieve the value of the nearest text input using JavaScript?

I am currently working on designing an HTML table that includes a time picker in one column for the start time and another time picker in a separate column for the end time within the same row. My goal is to retrieve both values (start time and end time), ...

How to attach an event listener to an input element using Angular

I am looking to add a listener to an input element that will be triggered every time the user changes the input values. The goal is to display the current values chosen by the user. Example HTML template: <div id="idDoseLabel1" class="da ...

npm installation for phonegap failed due to shasum check discrepancy

I've attempted numerous times, but I keep encountering this error (shasum check failed) 4784 error Error: shasum check failed for C:\Users\FENGXI~1\AppData\Local\Temp\npm-7004-QbpFFte5\1387269030233-0.28223602287471 ...

Is there a way to dynamically expand and collapse all table rows, with the latest row always remaining visible, using pure JavaScript?

I have a form input field where I enter data. The entered data is then displayed in a table as a new row, with the most recent entry at the top. What I want to achieve is to show only the newest row in the table and hide all other rows. When I hover over ...

Example of Image Slider using AngularJS

<body ng-app="myApp"> <div ng-controller="slideShowController" class="imageslide" ng-switch='slideshow' ng-animate="'animate'"> <div class="slider-content" ng-switch-when="1"> <img src="../images/ship.png" /> & ...

The z-index issue with Bootstrap modal is not being resolved on Firefox and Internet Explorer

I am encountering an issue with my bootstrap modal that includes a jquery datepicker. Specifically, the datepicker is styled as follows: .datepicker{ z-index:1000;} Interestingly, it functions perfectly on Google Chrome, displaying like this: However, ...

What are the benefits of utilizing the useStyles MaterialUI function instead of traditional CSS?

As I develop my MERN application, I am utilizing Material UI components along with inline attributes. However, I find myself questioning the necessity of creating a JavaScript file just to import the makeStyles function, which essentially outputs an obje ...

Implementing custom styles in JavaScript according to the specific browser or platform

When it comes to adding multiple css styles to a dom element and ensuring compatibility across different browsers, which approach is more optimal for performance? Combining all prefixed css properties together, allowing the browser to decide which one ...

Even when the dimensions are set to 100 width and height, the scroll bar still makes an

I recently embarked on my journey to learn web development by enrolling in a course on Udemy. Currently, I am diving into CSS3/HTML5 and have started a small project involving CSS3 - creating a web page that represents the Universe. My goal is to incorpora ...

Mastering the art of positioning images using CSS and HTML in email marketing

Currently in the midst of designing an email template for a new project. I have set up a table, with one row featuring some stripes and the next row showcasing a black bar to match the site's layout. My question is: Is there a way to incorporate an i ...

Divs are being obstructed by the navigation bar

I am seeking a solution to prevent div elements from being positioned below my navigation/information bar when the screen width is minimized. The information bar has a height of 1200px and I would like it to stay on the left side without any overlapping fr ...

PHP script not refreshing properly on reload causing randomized content to display inaccurately

In an attempt to create a dynamic website that features a random image on each page refresh, I have stored all images in a directory named "/pngs/" and set up a MySQL database with indexed rows for reference: <img src="pngs/000.png"> <img src="pn ...

What is the best way to create a miniaturized image of a webpage for sharing on Facebook?

I'm looking for a way to post a link to users' Facebook walls with a thumbnail image of their created page. The page is in HTML format and stored as a series of 'elements' in the database, each with its size, position, and content. Is i ...