Is the row border camouflaged by the background?

feed_page: {
    margin: 'auto'
  },

  feed_list: {
    margin: 'auto'
  },

  feed_item: {
    textAlign: 'center',
    backgroundColor: '#fff',
    borderBottom: '1px solid #e0e0e0',
    margin: '10px'
  }
  // ...
  <
  div style = {
    this.stylesheet.feed_page
  } >
  <
  List style = {
    this.stylesheet.feed_list
  }
height = {
  1400
}
rowCount = {
  this.testPosts.length
}
rowHeight = {
  50
}
width = {
  800
}
rowRenderer = {
  this.b_listItemRender
}
/> <
/div>

listItemRender({
  index, // Index of row
  isScrolling, // The List is currently being scrolled
  isVisible, // This row is visible within the List (eg it is not an    overscanned row)
  key, // Unique key within array of rendered rows
  parent, // Reference to the parent List (instance)
  style
}) {
  style = {
    ...style,
    ...this.stylesheet.feed_item
  }

  return ( <
    div key = {
      key
    }
    style = {
      style
    } > {
      this.testPosts[index]
    } <
    /div>
  );
}

that leads to (I manually adjusted the background for one row):

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

There are two problems:

  1. The spacing between rows is not consistent

  2. The borderBottom appears behind the next row's background, but shifting down by 1px or setting a height of 49px resolves the issue.

What did I do wrong? I want each row to have a border and be spaced properly.

Answer №1

To achieve the desired outcome, it is recommended to follow the options below:

  1. Margin - Add a margin in pixels to the top of the next element for proper spacing.

    First Element - top 50px
    Second Element - top 61px (50px + 1px border + 10px margin)
    Third Element - top 122px (61px + 51px + 10px margin)

  2. Height = height of the content. (Borders and padding are excluded from the calculation.) Therefore, the height of the element would be 50px + bottom border 1px, meaning the next element should start at top 51px and the third element at top 102px (51px + 51px).

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

Code sample: https://codepen.io/nagasai/pen/YaXVox

<div style="width:auto;height:250px;max-width:800px;max-height:250px;overflow:hidden;position:relative;border:1px solid blue;">
  <div style="width:100%;height:50px;max-width:800px;max-height:250px;overflow:hidden;position:absolute;top:0;margin:10px;border-bottom:1px solid black;background-color:red">i'm a post</div>
  
  <div style="width:100%;height:50px;max-width:800px;max-height:250px;overflow:hidden;position:absolute;top:61px;margin:10px;border-bottom:1px solid black;background-color:red">i'm a second post</div>
  
  <div style="width:100%;height:50px;max-width:800px;max-height:250px;overflow:hidden;position:absolute;top:122px;margin:10px;border-bottom:1px solid black;background-color:red">i'm third post</div>
</div>

Option 2: Another way to address this issue is to create a class with the following CSS:

.row{
width:100%;
height:50px;
max-width:800px;
max-height:250px;
overflow:hidden;
margin:10px;
border-bottom:1px solid black;
background-color:red
}

Explanation:

Remove position absolute and top properties, so that margin takes care of spacing and border-bottom.

Code sample for option 2: https://codepen.io/nagasai/pen/aYOwNm?editors=1100

.row{
width:100%;
height:50px;
max-width:800px;
max-height:250px;
overflow:hidden;
margin:10px;
border-bottom:1px solid black;
background-color:red
}
<div style="width:auto;height:250px;max-width:800px;max-height:250px;overflow:hidden;position:relative;border:1px solid blue;">
  <div class="row">i'm a post</div>
  
  <div class="row">i'm a second post</div>
  
  <div class="row">i'm third post</div>
</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

Apply a patterned background with CSS styling

I have tried to implement a custom CSS design using the background image bg.jpg with a pattern of dots.png that repeats both horizontally and vertically. *{ margin: 0; padding: 0; } body { margin: 0px; padding: 0px; color: #666; fo ...

"Accessing parameters with React Router's useParams function results in

Can someone help me with an issue I'm having while trying to print the topicId extracted from the URL? Every time I try, it keeps returning as undefined. Any ideas on what may be causing this in the code below? import React, {useState, useEffect, useR ...

Centering a button within a table-cell through movement

I'm facing an issue with aligning a button placed inside a table cell. The table setup is as follows: <b-table v-if="rows.length" :thead-tr-class="'bug-report-thead'" :tbody-tr-class="'bug-report-tbody& ...

What is the best way to use CSS to center two blocks with space in between them?

My goal is to achieve a specific design: I want two text blocks with some space in between them aligned around the midline of the page (refer to the image). I have experimented with the float property, as well as used margin and padding to create the gap ...

Enhance your table layout with Bootstrap 3 by adjusting textarea size to fill

I am currently in the process of developing a forum and bulletin board software. I am facing some challenges while trying to integrate a reply section into the thread page. You can view what I have implemented so far here. Html: <div class="panel pane ...

How can I emphasize the React Material UI TextField "Cell" within a React Material UI Table?

Currently, I am working on a project using React Material UI along with TypeScript. In one part of the application, there is a Material UI Table that includes a column of Material TextFields in each row. The goal is to highlight the entire table cell when ...

Issue with rollover button function in Firefox and Internet Explorer when attempting to submit

I have created a rollover submit button using HTML and JavaScript: <input type="image" id="join" name="join" src="images/join.png" value="join"> My JS code implements the rollover/hover effect: <script type="text/javascript" charset="utf-8"> ...

"Mastering the power of ReactJS with Promise.all

I'm struggling to ensure 'studentDataPromise' resolves before 'fetchLoansPromise'. It's crucial to fetch the student data first in order to fetch the loans. Any insight on what might be causing this issue? Current Status: t ...

Implementing a Responsive Form on an Image Using Bootstrap

I am facing a challenge where I need to position a form on top of a Responsive Image. My goal is to ensure that the form is responsive as well and adjusts its size according to the image. As of now, the image is responsive but I am struggling to make the ...

Implementing Date Object Display in a React Application

Trying to integrate the current date into a React project, but encountering an error. The code involves creating a Date object and displaying it on an h2 tag: import logo from './logo.svg'; import './App.css'; function App() { const c ...

Guide to utilizing SVG animations for line drawing rather than just outlines

I've been experimenting with animating an SVG file to resemble the gif below, and I'm getting pretty close, but I seem to be encountering an issue where the outlines are drawn before being filled. I want the entire lines to be animated as shown i ...

What is the best way to update properties in a child component using React hooks?

Looking to update the props using react hooks, I came across a method of passing setState function as props to the child component. MainContainer.tsx const MainContainer: React.FC = () => { const [count, setCount] = useState(0); return <Counter ...

Enhancing TextFields with React Material Margins

I am facing a simple issue where I attempted to add marginButtom to the TextFields but for some reason, it is not applying any margin. Please take a look at this codesandbox link CLICK HERE CODE <label>Schedule</label> <Te ...

Launching the date/time selection tool through code in the Material UI framework

I'm currently working on a project that involves React and Material Design. I decided to utilize Material UI for its sleek Dat- and Time Pickers components. In my application, I have to set Start and End Times and Dates in a specific order. To stream ...

What could be causing these warnings to pop up when I am utilizing the useEffect hook in React.js?

Having some trouble with React hooks and JS. I keep getting warnings about missing dependencies in my code, even after reading the documentation. It's all a bit confusing to me. ./src/CustomerList.js Line 32:6: React Hook useEffect has a missing d ...

What is the proper way to combine two arrays containing objects together?

I am faced with the challenge of merging arrays and objects. Here is an example array I am working with: [ { name: "test", sub: { name: "asdf", sub: {} } }, { name: "models", sub: {} } ] ...

PHP function that allows toggling only the first item in an accordion

In my function.php file in WordPress, I have the following code that is called using a shortcode on certain pages. It loops through and displays FAQs stored with each post. However, I am facing an issue where only the first accordion item can be toggled, ...

Attaching a Stylesheet (CSS) without being inside the HEAD Tag

After seeing numerous inquiries about this topic, I have yet to find the answer I seek. My main question is whether it is feasible to connect an external stylesheet in a location other than the HEAD tag. I am facing this issue because I need to use Conflu ...

Guide on making a JavaScript button with both "light and dark" modes

Currently, I am attempting to change the color scheme of the page by adjusting the :root variables using a function called changeBackgrondColor(). This function is then assigned to the fontAwesome moon "button". However, when I click on the moon, the pag ...

What is the best way to incorporate right side padding into a horizontal scroll?

I'm attempting to include padding on the right side of a horizontal scroll so that the last item in the scroll appears in the center of the screen. Here's what I have tried so far. While the left padding works perfectly, I'm puzzled as to w ...