Joy of CSS

505
0
03-18-2015 10:59 AM
VinceAngelo
Esri Esteemed Contributor
0 0 505

So I needed to add a button to an existing JavaScript/HTML app to fire a servlet app I had written.  The existing UI had a button on the top-left and a text banner in the top-middle, so I figured I could add the new button after the center text and all would be well, right?  Uh, no.

I added the button, and it wasn't displayed:

I was able to use Firebug to verify the new button was added, but it got wedged under other panels in the interface, and wasn't clickable.  Doh!

The solution was easier than I thought.  In frustration, with a delivery deadline looming, I decided to add the button between the original button and the banner, and lo and behold, the button appeared, in the right place!

It was only after I thought about it for a while that the behavior made sense.  The first button had: 

    dojo.create("div", {
            className: "expandRightIcon",
            style: {
                    marginLeft: "6px",
                    marginTop: "7px",
                    display: "inline-block",
                    float: "left"
            },
            title: "Hide Panel",
            onclick: (function(thisPanel) {
                    return function() {
                            dojo.publish(/*redacted*/);
                    };
            })(this)
    }, mainHeader);

But the banner was just:

    dojo.create("div", {innerHTML: "Results"}, mainHeader);

So when I added:

    this._reportButtonDiv = dojo.create("div", {
            className: "openReportIcon",
            style: {
                    marginRight: "6px",
                    marginTop: "7px",
                    display: "inline-block",
                    float: "right"
            },
            title: "Generate Attribute Report",
            onclick: (function(thisPanel) {
                    return function() {
                            dojo.publish(/*redacted*/);
                    };
            })(this)
    }, mainHeader);

after the Results div, there wasn't anywhere for it to "float".  But by placing the left, then right buttons, then adding the generic div, the browser was able to figure out what I wanted.

Tags (3)
About the Author
Thirty-five years with Esri, with expertise in Software Engineering, Large Database Management and Administration, Real-time Spatial Data Manipulation, Modeling and Simulation, and Spatial Data Manipulation involving Topology, Projection, and Geometric Transformation. Certifications: Security+ (SY0-601), Esri EGMP (2201), Esri EGMP (19001), Esri EGMP (10.3/10.1), Esri ESDA (10.3), Esri EGMA (10.1) Note: Please do not try to message me directly or tag me in questions; just ask a question in an appropriate community, and if I see it, have something to add, and have the time, I'll respond.
Labels