Avatar of Crystal Rouse
Crystal RouseFlag for United States of America

asked on 

Using Inline Styling with React

Using React and inline styles.  I have a div that I want to eliminate the bottom padding or margin.

This does not work:

const divStyle = {
    color: 'red',
    paddingBottom: 0

};

                        <label className="col-xs-1">
                            <div style={divStyle}>*</div>
                          First Name
                        </label>
ReactCSSHTMLC#

Avatar of undefined
Last Comment
Julian Hansen
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

paddingBottom: 0

should be

padding-bottom: 0
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Scratch that ! Forgot about the camelCasing in React (why!).

What does the HTML code look like after you've rendered it. You may have other CSS somewhere that's overriding it.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

<div style={divStyle}>*</div>

Open in new window

Why would this div have any padding - <div> elements by default do not have padding?

Are you sure that is where you want to remove the padding from?
ASKER CERTIFIED SOLUTION
Avatar of Crystal Rouse
Crystal Rouse
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

display: 'inline' 

Open in new window

Ok so you want the div to be inline with the other content - why not just use a <span> - why use a block element and then inline a style to turn it into an inline element when <span> ill do the job for you?
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo