English 中文(简体)
Jquerycs公司的职能是利用地图中的所有论点。
原标题:Jquery css function doesnt use all the arguments in a map
  • 时间:2012-04-25 07:28:53
  •  标签:
  • jquery
  • css

In one of my webApp methods, I create html elements dynamically and add a dynamically made css object using this code :

    tag = typeof(tag) !==  undefined  ? tag : "div";
    end = typeof(end) !==  undefined  ? end : true;
    var html =  < +tag+  value=" +this.id+ " class="element  +this.type+ " +
                 style="position:absolute;z-index=  +this.id+ " 
    end ? html += "></"+tag+">" : html += "/>";
    var css = {},element = this;
    $.each(this.properties(),function(){
        var hash=this.indexOf("Color") !== -1? # :  ;
        var property = typeof(element[this])=== number ?element[this]*Nx.ratio:element[this];
        css[this]=hash+property;
    })
    console.log(css);
    html = $(html).css(css);
    $( .page[value= +page+ ] ).append(html);

Here is an example of css object taken from my console.log that was created and passed to the css() function :

Object
backgroundColor: "#ff0000"
borderColor: "#ffffff"
borderStyle: "solid"
borderWidth: "0"
height: "56.865"
left: "0"
top: "274.29"
width: "893.115"
__proto__: Object

现在的问题是,产出要素具有顶、左、高和湿度,例如:

<div value="12" class="element rectangle" style="position: absolute; background-color: rgb(255, 0, 0); left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-top-color: rgb(255, 255, 255); border-right-color: rgb(255, 255, 255); border-bottom-color: rgb(255, 255, 255); border-left-color: rgb(255, 255, 255); border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; "></div>
最佳回答

These CSS properties are not applied to your element because you do not specify them properly. The values of left, top, width and height have to be:

  • Either a number, such as 0 or 274.29,
  • Or a string followed by a unit suffix, such as "0px" or "274.29px".

你们的法典使用了没有一股子的扼杀装置,因此,这些价值被视为无效,其财产被忽略。

问题回答

你们的法典会有一些问题。 确切地说,错误在哪里发生,但你又找不到<条码>;

... style="position:absolute;z-index=  +this.id+ " ; <-- there!

Also this:

tag = typeof(tag) !==  undefined  ? tag : "div"

大部分时间也可以写成:

 tag = tag ||  div 

也许你的问题是在这里的,现在还有许多<条码>。

$.each(this.properties(), function () {
    var hash = this.indexOf("Color") !== -1 ?  #  :   ;
    var property = typeof(element[this]) ===  number  ? element[this] * Nx.ratio : element[this];
    css[this] = hash + property;
})

The sthis.properties (). 页: 1 同this dans each(......)? Seems as a source of wrong where...





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签