Giter Club home page Giter Club logo

Comments (7)

inferpse avatar inferpse commented on May 31, 2024

Hi, @NigelOToole !

JCF library tries to avoid inline styles on the fake select element so you don't have to worry about priority of your CSS rules vs inline html styles.

Responsive behavior can be achieved with CSS. For example you have:

<select class="foo">...</select>

Now you can control styles of custom select like this:

select.foo,
select.foo + .jcf-select {
    width: 50%;
}

Or you can use the class of your select element which is automatically copied and prefixed with "jcf-select-" by JCF library:

.jcf-select-foo {
    width: 50%;
}

Will this work for your case?

from jcf.

NigelOToole avatar NigelOToole commented on May 31, 2024

Hi

Thanks for the reply and I can understand trying to avoid inline styles but
this is the only way I could always get them to line up.

I have already tried using styles as suggested but this didnt work. The
strange thing is that my developer tools in firefox are saying all the
element, the native select, the jcf-select and the jcf-select-drop have the
same pixel width but the edges dont line up untill I added the inline
styles.

Regards,
Nigel

On 23 June 2015 at 17:11, Sergey [email protected] wrote:

Hi, @NigelOToole https://github.com/NigelOToole !

JCF library tries to avoid inline styles on the fake select element so you
don't have to worry about priority of your CSS rules vs inline html styles.

Responsive behavior can be achieved with CSS. For example you have:

...

Now you can control styles of custom select like this:

select.foo,select.foo + .jcf-select {
width: 50%;
}

Or you can use the class of your select element which is automatically
copied and prefixed with "jcf-select-" by JCF library:

.jcf-select-foo {
width: 50%;
}

Will this work for your case?


Reply to this email directly or view it on GitHub
#6 (comment).

from jcf.

inferpse avatar inferpse commented on May 31, 2024

Ok. Are you testing on the retina display?
Maybe you could provide a jsfiddle, so I can reproduce the issue?

BTW, you can try fakeDropInBody: false option which will put the drop inside the fake select element and it will have the same width as the container without any inline styles.

from jcf.

inferpse avatar inferpse commented on May 31, 2024

Need more information to reproduce the issue.

from jcf.

nikolai-katkov avatar nikolai-katkov commented on May 31, 2024

Having the same issue in Bootstrap 3. It is caused by jQuery outerWidth() behavior, it rounds the actual width. I managed to solve it in jcf.select.js, function repositionDropdown (line 309):

selectWidth = this.fakeElement.outerWidth(),

replace it with

selectWidth = this.fakeElement[0].getBoundingClientRect().width,

(see stackoverflow to take care about browser support)

from jcf.

nikolai-katkov avatar nikolai-katkov commented on May 31, 2024

If you wish, I could make a pull request (browser-safe version of this comment).

from jcf.

inferpse avatar inferpse commented on May 31, 2024

Ok, so .offset() already returns floating point value and only width is calculated with rounded values. I think this is the only place that needs to be updated in jcf.select module.

@nikolai-katkov will be waiting for your PR ;)

from jcf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.