Skip to content
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

Why not using CSS Selector and text align classes ... #268

Open
effone opened this issue Jan 25, 2018 · 6 comments
Open

Why not using CSS Selector and text align classes ... #268

effone opened this issue Jan 25, 2018 · 6 comments

Comments

@effone
Copy link

effone commented Jan 25, 2018

  1. Was wondering why there are all lengthy 88 lines covering every single class instead of where we can cover the same with only 8 lines...
[class^="col-"] {
    box-sizing: border-box;
    -webkit-box-flex: 0;
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

Is there any specific reason?

  1. Also was wondering if there were some text align classes as well that would be helpful ...
/* Responsive text alignments */
.col-xs-txr {
	text-align: right;
}

.col-xs-txm {
	text-align: center;
}

.col-xs-txl {
	text-align: left;
}

@media only screen and (min-width: 48em) {
	.col-sm-txr{
		text-align: right;
	}
	.col-sm-txm{
		text-align: center;
	}
	.col-sm-txl{
		text-align: left;
	}
}

@media only screen and (min-width: 64em) {
	.col-md-txr{
		text-align: right;
	}
	.col-md-txm{
		text-align: center;
	}
	.col-md-txl{
		text-align: left;
	}
}

@media only screen and (min-width: 75em) {
	.col-lg-txr{
		text-align: right;
	}
	.col-lg-txm{
		text-align: center;
	}
	.col-lg-txl{
		text-align: left;
	}
}
@Cookizza
Copy link

Cookizza commented Feb 7, 2018

Firstly, those text align classes would be a great addition.

However your first point is not the same.

[class^="col-"] will not match classes that are not the first in the class list (e.g. class="something col-md-12") will not be matched by CSS exporters / bundlers. Which will cause really annoying behavior to anyone using webpack bundler :s

@dark-side-coder
Copy link

@Cookizza There is a way around it not being listed as first in the class list. By using the [class*=" class-prefix-"] attribute selector. Basically, by adding a space before the class prefix, it will account for any element that contains the class if it is not the first within the class list. Combine this with the method mentioned by @effone and together it should solve that issue.

However, I am not sure what the impact this would have to webpack bundler.

[class^="col-"], [class*=" col-"] {
  /* styles go here */
}

@Jessman5
Copy link

Jessman5 commented Jan 18, 2019

[class*="foo"] means: if selector classes contain a class named foo. It doesn't matter if foo is the first, the last or whatever class.
[class^="foo"] won't be needed then, especially not in combination with [class*=" foo"].

@AfonsoFG
Copy link

AfonsoFG commented Jun 22, 2019

@Jessman5 Do notice he has [class*=" col-"] and not [class*="col-"]

@Jessman5
Copy link

@AfonsoFG yes, that'S why I wrote the comment. you don't need the space here. In fact [class*=" col-"] will only fire when you have class=" col-..." and not when you have class="col-..." that could or will cause some trouble.

@AfonsoFG
Copy link

And the @dark-side-coder comment covers just that ... but I might be confused... at this point of the day the brain doesn't seems to keep up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants