Cell borders in an HTML table are covering up the table borders

I am currently facing an issue with displaying an HTML table in a UIWebView within my iOS app. The table itself looks great, but the borders of the cells and rows are overlapping the main table border.

Here's an example:

To style these borders, I have applied CSS classes directly to the HTML. Here is how my stylesheet is structured:

<style type='text/css'>table.tdat{border-collapse:collapse;border-color:#000000; border-style:solid; border-width:1px;}td{padding:2px; font-family:Helvetica; color:black; font-size:12pt; height:15pt; text-align:right; vertical-align:top; white-space:nowrap;}tr.cta td{font-family:Arial; color:black; font-size:12pt; height:15pt; text-align:right;vertical-align:top;white-space:nowrap;border:1px solid #eeeeee;}tr.top td { border-top: thin solid black; }tr.bottom td { border-bottom: thin solid black; }tr.ax td:first-child { border-left: thin solid black; border-right: thin solid black;} </style>

The formatting above is included in an NSString, and while I'm familiar with using CSS for iOS apps, I may not have gotten the syntax right.

For applying this CSS to the table, here is how it's implemented:

<table frame="box" class="tdat">
 <tr class="cta top ax">
  <td>Position:</td>
  <td width="20">1</td>
  <td width="20">2</td>
  <td width="20">3</td>
  <td width="20">4</td>
  <td width="20">5</td>
  <td width="20">6</td>
  <td width="20">7</td>
  <td width="20">8</td>
 </tr>
 <tr class="cta bottom ax">
  <td>Axis A:</td>
  <td>4</td>
  <td>3</td>
  <td>2</td>
  <td>2</td>
  <td>1</td>
  <td>3</td>
  <td>3</td>
  <td>2</td>
</table>

Answer №1

The reason for the extra pixel in the side borders of the td is due to setting borders on the top and bottom, causing them to overlap. To resolve this issue, you can make some adjustments by adding cellspacing="0" to the table HTML and removing border-collapse: collapse;. Then, you can style the borders as needed.

table.tdat{
  /*border-collapse:collapse; remove */
  border: 1px solid black;
}
td{
  padding:2px; 
  font-family:Helvetica; 
  color:black; 
  font-size:12pt; 
  height:15pt; 
  text-align:right; 
  vertical-align:top;
  white-space:nowrap;
}
tr.cta td{
  font-family:Arial; 
  color:black; 
  font-size:12pt; 
  height:15pt; 
  text-align:right;
  vertical-align:top;
  white-space:nowrap;
  border:1px solid #eeeeee;
  border-top: 0; /* ADD */
  border-bottom: 0; /* ADD */
}
/*tr.top td {
  border-top: thin solid black; REMOVE
}*/
tr.bottom td { 
  /*border-bottom: thin solid black; REMOVE*/
  border-top: 1px solid #eee;
}  
tr.ax td:first-child { 
  /*border-left: thin solid black; REMOVE */
  border-right: thin solid black;
  border-top-color: black;
}

http://jsbin.com/IQuYIBI/1/edit

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

Pass the ID to a PHP script to retrieve the image source tag from the database based on the file

I am facing a challenge that I thought would be simple, but despite my efforts to research and experiment, I can't seem to get it right. I have a database that stores image file names, and I need to retrieve the file name based on the ID specified in ...

How can I utilize JQuery to dynamically refresh a dropdown menu?

My dropdown list is initially empty: <div> <label>Boarding Point </label> <select title="Select pickup city" id="boardingDropdown"> </select> </div> I am trying to popula ...

What are the essential requirements to fully implement Ext.QuickTips()?

I'm revisiting a previous question, with a focus on the concept rather than my specific issue. Currently exploring Saki's Form Examples, specifically, Displaying Form Submit Errors. Using Ext-JS 3.3.0 and aiming for similar functionality in my d ...

Is there a way to turn off _moz_resizing on my browser?

I am currently using the nicEdit editor and have successfully integrated my own custom image resizing script. However, I am facing an issue where the default _moz_resizing feature in Firefox is interfering with my custom script. My goal is to have specifi ...

Encountered an error: Uncaught TypeError - Unable to access the 'format' property of an undefined object at the specified time

I encountered an issue with the following line of code let FullDate = moment(1499153561479).add(currentSeconds, 'seconds').tz(citiesT[id]).format("DD-MM-YYYY HH:mm:ss a"); Any suggestions on how to resolve this error? ...

Iterating through a nested array in order to dynamically generate elements using JavaScript/jQuery

Seeking assistance with a specific issue I am facing. Despite extensive research on this platform, I have not found a solution to my problem. Recently, I successfully used jQuery each to loop over objects. However, I am currently struggling to iterate thro ...

Divide Footer Information into Two Sections: Left and Right

<footer> <div class="copyrights-left"> <p>&copy 2015. <a style="color: #fff;" href="index.html">Free Xbox Live Gold Membership and Free Xbox Live Gold Codes</a>. All rights reserved.</p></div> <div class="co ...

Using Angular 4 constructor value in a condition with *ngIf

Within this TypeScript snippet, there is a variable called moreinfo that is initially set to 1. In the constructor, however, the value of moreinfo is changed to 2. Subsequently, based on whether the value is 1 or 2, different div elements are displayed usi ...

Fixing the hydration error in Next 13 can be challenging, especially when it occurs outside of a Suspense boundary

Encountering an issue while working with Next.js 13: Error: Hydration failed because the initial UI does not match what was rendered on the server. Warning: Expected server HTML to contain a matching <div> in <html>. Every time I attempt to r ...

utilizing the target attribute within a form to open the link in the current page

I have been working on a web application and implemented a drop-down menu using a form to display information about the selected category. However, I noticed that when an option is selected, the link opens in a new window instead of the same window. Below ...

The naming convention for CSS classes could be defined as follows: .sa-list li a > div{

As I dive into a CSS example, one particular section of code catches my eye: .sa-list li label > span, .sa-list li h3 > span, .sa-list li h4 > span, .sa-list li a > div{ position:relative; display:table-cell; vertical-align:middle; ...

What is the best way to align a square div in the center between two columns using Bootstrap?

I am working on a layout that consists of two columns in a row with col-6, and a jumbotron. Here is the code snippet I have: <div class="jumbotron text-left" style="background-image: url(https://mdbootstrap.com/img/Photos/Others/gradient1.jpg); backgro ...

Merging the HTML and JQuery scripts to create a unified webpage

My Website Dilemma: Working with Intuit Web Designs has presented me with a unique challenge in terms of HTML setup. The platform requires me to paste anything within the <head></head> tags in a separate box, rather than directly into the main ...

add a border to an image when it is hovered over

I'm having trouble getting the hover effect to work on my images. I suspect that I may be targeting the CSS hover incorrectly, and there could also be a conflict with the jQuery code that is attached to the images. Here is the link to the fiddle: ht ...

Unusual mobile chrome behavior and erratic modal functionality

It has come to my attention that mobile users on Chrome/Android are experiencing some unusual behavior with modals. The autofocus feature is not working as expected, and the view keeps scrolling to the bottom. This issue specifically occurs with modals th ...

The Bootsrap modal fails to open when triggered by a different button

Why does the login button open a signup modal instead of a login modal, even though they are configured in the same way? I renamed the login button to 'loginModel', but it still doesn't work as expected. However, the sign-up button works cor ...

Even after utilizing box sizing, additional margins are still contributing to the overall width calculation

Having an issue where the margin of my elements is affecting their total width, even with the box-sizing: border-box property in place. There are 2 elements - a sidebar and main content div - that stack neatly until margins are added and the sidebar moves ...

Animating colors with jQuery and shifting SVG shapes to create dynamic and

I am currently working on an svg animation that involves changing the color of the svg to a different color, creating a running light effect. Rather than fading the fill color of the entire svg as commonly seen in examples, I aim to achieve a dynamic trans ...

Main content with a floating aside menu

I am currently using the CoreUI admin template. The layout I have set up is the basic one outlined on the following page: My goal is to make the aside menu appear on the right side of the main content, floating over it rather than inline and reducing the ...

What is the process for displaying a partial view upon clicking an image?

I am reaching out to you because I need some guidance. My goal is to design a webpage featuring 3 clickable images. Upon clicking an image, I want a specific partial view to display on the same page. If another image is clicked, all other partial views ...