GWT setWidth and Internet explorer - css

I've created a custom widget, which uses a bunch of floated divisions, I'm having a issue with internet explorer though. After playing around a bit, I found that the problem was with setting inline css.
I have a class extending ComplexPanel, which sets the element to a division, and offers a bunch of helper functions to set various inline CSS.
If I add say, 3 divisions using this DIV wrapper class, which all are being floated left, and set to 100px using inline css (set with getElement().getStyle().setProperty()), then they act odd in IE8. (it works fine in IE9).
Basically, none of the inline CSS is being picked up. Using the developer tools shows the CSS is there, but its not being applied. If I disable the float (or width for that matter) and enable it again, using the developer tools, the inline CSS is picked up and it works as intended.
So, how can I inform IE8 that it needs to re-interpret inline CSS on dynamically generated elements?

We had problems using setProperty()... in ie8. So, avoid it.
Try using one of predefined methods in Style.
Try using getElement().getStyle().setFloat(Float.Left).
and getElement().getStyle().setWidth(100, Unit.PX).

Related

Tinymce 4 inline css content applied to page instead of div only

I have a div and apply the latest version of tinymce (4.2.5) to it, including some of my websites stylesheets.
When I use the editor old fashioned way the loaded css is only applied to the div I'm attaching tinymce to. Like a charm.
But I want to use the inline: true option. When I use that all the css is applied to the complete page of the application, not only the div.
Is this expected behavior? Or should I look for another approach? My main reason to use the inline feature is that it keeps the toolbar visible on scrolling. Unfortunately tinymce loads different sets of html for the inline and fixed toolbar (for example, the menu bar and icon/tool bar are separate div's. On inline they have a parent div) so just applying the same or similar css isn't working out.
Anybody has any tips or tricks for me? Or should I accept the limitations of one or the other?
You will have to accept the limitations.
Both editor modes need different css for the UI and in inline mode it seems to be necessary to apply it to the complete page (even though you don't like that).

CSS pseudo after/before using content or background for img?

As for pseudo-elements :after/:before there are apparently two ways if I want to display image there:
using background-image:url(imgurl.png);
using content:url(imgurl.png);
Are both ways correct and valid? Why should I be using one way over another?
Apparently using the second method you cannot set the picture properties like size. But first method is generaly more taught on internet.
Ideas?
It depends on what your image is, just like the debate between using an <img> tag vs using background-image in your CSS.
If your image is part of your page's content, use content:url(imgurl.png);. Certainly if you want the images to be interactive or to to inform the user's experience while on your page, use content. If your image is just stylistic for your site's visual design, use background-image:url(imgurl.png);
Also, do note that you should use double colons: ::before and ::after. Only IE8 requires the single-colon versions.

How do I make a sub menu link become the head link in css dropdown menu without the use of javascript or jquery?

I'm very new to this and don't know how to use javascript or jquery and would prefer to avoid using it in all possible cases as I know it's not compatible in all browsers, takes time to load and can be disabled by users.
I've already made and designed the menu but would like the main heading in the menu to change to the submenu link when clicked on whilst keeping the rest of the menu in tact. How do I achieve this in css?
You can take a look at http://davidwalsh.name/css-target and use the css target selector (But it's not supported in IE - I haven't checked IE10 though).
but-
If you want to change the text or href attribute then, it's not possible in pure css (correct me if I'm wrong). You would have to use javascript. Jquery makes it easier to make your site support most used browsers, why not give it a go? I am certain if you get stuck, people on Stack overflow would gladly help you.
on a sidenote, css can also be disabled by the user (and not all browsers support all css features). Css and Javascript are in the same boat, because the browser dictates what is supported.

Is there a browser extension to get all the CSS that is applied to a DOM element?

Firebug is great, and allows me to see all the CSS applied to an element in the DOM that you select, but either you can:
a) View it line by line, as defined in the CSS, in the applied order (very useful but not what I'm looking for) or
b) View it "computed", which is all CSS rules and the values that this element has.
What I want is a tool or extension that allows me to select an element and would show me, in copy-pastable form, all the CSS that's been defined for that element. If the element has font-style:normal just because it's the default for that element, I don't want that there (Firebug shows all this in computed view).
Basically I want to be able to:
I see an element I'd like to replicate on a website (like a button) exactly in my own website.
Use this tool to get a bunch of CSS applied to that element.
Paste on my own CSS.
Get the same looking element in my website. Yay!
Any ideas?
Switch to Chrome default element inspector (press F12), it has all that you need. You'll find everything in the Computed Style panel, including a useful "Show inherited" checkbox
I know the question is almost 4 years old, but if there is someone looking for it today, there's a Chrome extension that handles it. https://github.com/kdzwinel/SnappySnippet
It adds a new tab in Chrome Inspector and you just need to click a button to get all html and css of the selected element and its children. Then you can export it to codepen, jsfiddle and jsbin, or copy and paste.
Google Chrome has tools like Firebug built in called "Chrome Developer Tools". It is extremely powerful from my experience and I switched from Firefox/Firebug to Chrome about a year ago. There are several different ways to get the developer tools up. You can find detailed documentation at https://developers.google.com/chrome-developer-tools/docs/overview
When you have the Chrome developer tools open to the elements tab with an element selected, you can expand the computed styles area on the right and see all styles that make up that element.
If the specific style has an expandable triangle to its left, you can find out what stylesheet and where the styling comes from.
You don't need any extensions for that, the built-in inspector in Firefox can do that. Right-click the element, choose "Inspect Element". Click the Style button in the bottom toolbar - and there it is, a sidebar with all the styles applied to that element.
I have tried to calculate it via window.getComputedStyle and it is needed to be optimized to shake out unnecessary style properties. https://github.com/aleen42/DOM-mirror
I've tried SnappySnippet and found CSSSteal to be much better. It will grab just the CSS, and will do so in the same format as the document has it, unlike SnappySnippet.
There's an API on window Object >> window.getComputedStyle(DOMElement). This is if we need to work with computed styles programmatically.
MDN Docs for window.getComputedStyle
Good Luck...
You can try this extension https://getcssscan.com/?ref=beautifulcheckboxes_header but it is not free. I found this while I was finding a solution.

How do i find what is affecting the width of this div? CSS

I am messing with a wordpress theme. I am using firefox and have webdeveloper (and other tools) installed. I am trying to adjust a div width but it is not listening to me. I suspect theres a % used since when i tried setting a max-width to a parent it became MUCH shorter (then the size i specified). The style file is 3k... I tried narrowing it down but its troublesome.
What tools and technique can i use to spot the problem?
Use firebug and inspect the element to see all affecting attributes.

Resources