Css different style to specific div created by map

Active3 hr before
Viewed126 times

9 Answers


Stack Overflow Public questions & answers ,I am rendering a div multiple times by using map javascript function in my react application. I want to set css (width) of each element. Width will be element specific. I am rendering div like this,Thanks for contributing an answer to Stack Overflow!

That said, you could do apply an inline-styling instead:

  (item, i) => <div style={{width: (50 * i) + "%", height:(20 * item.time) + "%"}}></div>


  (item, i) => {
    let s = {
      width: (50 * i) + "%",
      height: (20 * item.time) + "%"
    return <div style={s}></div>;
load more v

var map;

function initMap() {
   map = new google.maps.Map(document.getElementById('map'), {
      center: {
         lat: -34.397,
         lng: 150.644
      zoom: 8

   $(document).bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', function() {
      var isFullScreen = document.fullScreen ||
         document.mozFullScreen ||
      if (isFullScreen) {
         console.log('fullscreen mode!');
      } else {
         console.log('not fullscreen mode!');
         var elem = map.controls[google.maps.ControlPosition.TOP_LEFT].pop();
load more v

I wish to be able to click on a div, and change its background color to white. everything I try will change the background of all the 10 divs to white. How can I make it so only the clicked one is changed?,this renders a list of divs, and I was able to change each div background, when hover, like this:,I am creating a list of divs, which was created with

 Pretag team - issue, fix, solve, resolve

 Pretag team - issue, fix, solve, resolve

Then, add the following to styles.css:,A matching CSS class selector in your stylesheet.,Go ahead and create that styles.css stylesheet in the same folder, too. This gives us everything we need to explore CSS selectors.

We’ll only need one HTML file and a CSS stylesheet for our example this chapter. Create a new folder called css-selectors and new web page called selectors.html with the following markup:

<!DOCTYPE html>
<html lang='en'>

   <meta charset='UTF-8' />
   <title>CSS Selectors</title>
   <link rel='stylesheet' href='styles.css' />

   <h1>CSS Selectors</h1>

   <p>CSS selectors let you <em>select</em> individual HTML elements in an HTML
      document. This is <strong>super</strong> useful.</p>

   <p>Classes are ridiculously important, since they allow you to select
      arbitrary boxes in your web pages.</p>

   <p>We’ll also be talking about links in this example, so here’s
      <a href='https://internetingishard.com'>Interneting Is Hard</a> for us to

   <div>Button One</div>


load more v

An inline CSS is used to apply a unique style to a single HTML element.,CSS saves a lot of work. It can control the layout of multiple web pages all at once.,An internal CSS is used to define a style for a single HTML page.

load more v

In CSS, selectors are patterns used to select the element(s) you want to style.,Use our CSS Selector Tester to demonstrate the different selectors.,If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

 Pretag team - issue, fix, solve, resolve

Put a div element with a certain id where you want your map to be:, Put a div element with a certain id where you want your map to be: <div id="mapid"></div> ,This step-by-step guide will quickly get you started on Leaflet basics, including setting up a Leaflet map, working with markers, polylines and popups, and dealing with events.

 <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />
load more v

The <div> HTML element is the generic container for flow content. It has no effect on the content or layout until styled in some way using CSS (e.g. styling is directly applied to it, or some kind of layout model like Flexbox is applied to its parent element).,<div>: The Content Division element,This element includes the global attributes.

   <p>Any kind of content here. Such as
      &lt;p&gt;, &lt;table&gt;. You name it!</p>
load more v

Other "specific-style" queries related to "Css different style to specific div created by map"