New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to use bulma media query mixins #1818
Comments
More or less bubbling something like this up to the docs: // sass/scss
.some-responsive-thing {
border: 1px dashed #990000;
@include until($desktop) {
border-bottom: 1px solid green;
}
@include from($tablet) {
border-left: 1px solid yellow;
}
@include tablet {
border-top: 2px solid orange;
}
@include widescreen-only {
border-right: 2px solid blue;
}
}
// output
.some-responsive-thing {
border: 1px dashed #990000; }
@media screen and (max-width: 1087px) {
.some-responsive-thing {
border-bottom: 1px solid green; } }
@media screen and (min-width: 769px) {
.some-responsive-thing {
border-left: 1px solid yellow; } }
@media screen and (min-width: 769px), print {
.some-responsive-thing {
border-top: 2px solid orange; } }
@media screen and (min-width: 1024px) and (max-width: 1167px) {
.some-responsive-thing {
border-right: 2px solid blue; } }
|
Bulma has shortcuts for that. Here's the source code: =desktop
@media screen and (min-width: $desktop)
@content So it's used as: +desktop
.is-invisible-desktop
visibility: hidden !important |
RIght right, this issue was to document, as in, make it part of the official docs. There are a number of good tools & utils like this that could be surfaced into the docs to be consumed by users of Bulma. |
@benjaminapetersen it's documented here. I had a bit of trouble finding it myself. |
I'm really getting at the use of @include from($tablet) until($widescreen) {
border-left: 1px solid yellow;
} Is quite powerful & useful. |
I see. I guess it could be included the docs. It could end up in “mixins” or “responsiveness”. Not sure how to word it though. |
RIght, looks like you have a set of pretty handy tools there. All these little bits help document how useful Bulma is. The only downside is surfacing as public API in docs, but if the helpers are stable, seems a good thing. |
I'm still working through the source, but betting you have other nuggets buried in there that would be great to expose. |
You can't combine mixins like this. |
Sorry to reopen this, but I have problems using the Bulma shortcut for this.
|
@ekntrtmz: +desktop
.section
padding: 3rem 0 Make sure you use tabs or spaces -- no curly braces needed. Hopefully it works for you. 😄 |
Hello so I use sass here, Is there any ways to use it? or just type |
@mandaputtra .container {
width: 100%;
max-width: 1200px;
} In .container
width: 100%
max-width: 1200px You can go here to have more info on how to use The @include desktop {
// Some content here...
} In +desktop
// Some content here... These breakpoints have to have some content, because of the way they are setup: =desktop
@content The I hope it makes sense, and that it helps. 😄 |
@jdriviere Hmm, i guess my question are not clear sorry about that. I mean if I set up my workflow maybe example with vue-cli and import bulma globaly that mean I by default can use those mixin? like
|
@mandaputtra I'm not too familiar with Vue, unfortunately. I'm sorry. I hope someone can answer your question soon, though... 😞 |
Ok I got it. @jdriviere When I removed the brackets it gave me a syntax error on scss. This is why I had to rename/change my file extension from @mandaputtra I am working with the vue-webpack setup. The above procedure did the job for me. Do not forget to change syntax and document reference within main.js ;) |
@ekntrtmz Did it work when you changed the extension from |
@jdriviere Yes it works now. It was not clear to me that |
Please, update docs for scss version. |
I'd take a guess and say most people are using and are used to the the scss way, docs should be clear for the scss people out there. |
I've created some functional CSS to speed up development like this:
The problem is that this will not only generate those classes but some extra css (it will compile the whole mixins.sass file) and this will lead into code duplication, in my case it will break modals position unless I import previous file before importing bulma in order to let bulma override generated code... Here is the generated code:
Here is what I expected:
EDIT: |
This definitely needs some examples in the documentation. I never used this powerful feature because I simply didn't understand what to make of |
Found this thread today after having looked through the docs for explanation on the responsive mixins and not finding it. Turns out it is there, but it's under the Responsiveness tab rather than the Mixins. I'd suggest adding the responsive mixins on the Mixins tab as well to simplify finding them for first timers and since technically the Mixins list is incomplete without them. Understanding the differences between sass & scss mixins should be more up to individuals and not necessarily the responsibility of Bulma to educate. Just my $.02 |
I think I agree with @benjaminapetersen. The responsive mixins list would benefit from adding the The |
I definitely agree as well @mkstix6. Perhaps what this is boiling down to is the Responsiveness & Mixins tabs in the docs would benefit from a refresh with some additional mixins and examples added. At the end of the day it really isn't a huge problem though, even a couple hours using Bulma can be enough to get familiar with the more intricate workings. The E.G. Edit: Fixed typo |
Does anyone have a simple working example yet?? I can't find one that works for my code anywhere. Using +mobile in css doesn't work, nor does using @include. All I want is to recognize when the screen is mobile so I can change the width of the avatar image to 25% from fixed width. Seems like it should be simple!! lol Your help is much appreciated! |
@samchasan You'll need to be using SASS/LESS/SCSS to make use of mixins as it's not feature native to CSS. After that it's just a matter of including the mixins you want as needed, E.G.
#avatar {
...
width 150px;
@include until($tablet) {
...
width: 25%;
}
} If you want to dig into how the responsive mixins work I'd suggest taking a look at the source here |
@curiouscrusher oooh got it thanks! I found this walk through finally in the docs that outlined the specific steps to get the scss file set up properly. And that suggestion helped clarify that's what I needed to do. So thanks again :) |
Where are we on this? It's not obvious from the docs how to use your media queries. You cite the variables but don't give examples of implementation. It's not good that we should have to guess. Bear in mind frameworks like these are often used by beginner developers so you shouldn't assume they will be au fait. For instance this doesn't work and throws a SCSS error:
|
@thomasabishop it should be like: @import "<mixins_path>"
.class {
@include desktop {
max-width: 800px;
}
} If you have already imported bulma main mixins will be available and won't need to re-import mixins. |
Can't but agree with the original sentiment, as I found it very quite confusing to get started due to lack of examples and having used the .scss syntax instead of .sass. Looking at the Responsiveness page, I was simultaneously impressed by the substance of the contents, and appalled by the lack of examples. I believe a few simple "this is how you apply them" would go a long way! |
If you would like to have a style applied between x pixels and y pixels you can simply do:
|
I am not sure but I have imported the mixin in my scss file but I cant seem to be able to use any of the following.
I read the mixins.sass and understand basics there but getting a simple media query to work is really painful. I agree with the OP that there needs to a simple section dedicated to this in documentation. |
Ok so to use both variables and the mixins, you need to import both sass files. To use the mixins (e.g. desktop-only, until($dimension): Hope that helps Edit: if you import the mixins sass file, you will not need to import the derived variables file. |
Can we add some examples in the documentation? This is a big problem with an easy fix. some more documentation at the point of reference. I will write the documentation, It will be fun. It's just incredibly frustrating to read the docs and still not understand how to get started. |
This is stil an issue. I have no idea how to properly use mixins together with my SCSS styles. @import "~bulma/sass/utilities/mixins.sass";
.hero-body {
@include until($touch) {
background-image: none;
}
@include from($desktop) {
background-image: url(../images/header-img.jpg);
background-position: center 70%;
background-size: cover;
height: 100%;
width: 100%;
}
} This gives me an error for $touch being undefined, even though it's defined in bulma's mixins.sass. I have also tried using How can I properly have all the breakpoint variables ($touch, $desktop, $tablet, $mobile etc.) available to me in my own SCSS files or use things like +desktop, +touch? |
Funny thing is that this issue was opened on Apr 2018 and its been 3 years now. The documentation still doesn't have this 😄 |
From the mixins.sass, touch is a media query.
Import mixins.sass and try using it like
|
- The white color was great until menu items were affected - Fixed with mixin from link below jgthms/bulma#1818 (comment)
This is about the Docs.
Overview of the problem
This is about the Bulma Docs
I'm using Bulma version [0.7.1]
Description
Bulma's media query mixins could be useful for styling custom components while using Bulma. It would be helpful to document this feature (ideally with side-by-side
sass
/scss
examples).Thx!
The text was updated successfully, but these errors were encountered: