-1

Is there a way to put a check in SASS files or CSS files to check for the content inside a div:

For e.g.: If a div has numbers in it I want the content inside it to be aligned to the right and whereas if the div has text in it I want the content to be aligned to the left.

Is it possible. I see it happening on a lot of websites, and I pretty sure that they must not have hard-coded it that way.

Thanks in advance.

cimmanon
  • 67,211
  • 17
  • 165
  • 171
Nick Div
  • 5,338
  • 12
  • 65
  • 127
  • possible duplicate of [is there a CSS selector for text nodes/elements?](http://stackoverflow.com/questions/5688712/is-there-a-css-selector-for-text-nodes-elements) – cimmanon Aug 19 '14 at 13:40

1 Answers1

0

no. thats not possible. you need to check it somewhere else.

you could for example check the content in php code and then depending on the type of content add a css-class to the parent html-element.

DerZyklop
  • 3,672
  • 2
  • 19
  • 27
  • The store returns so much data, I didn't want to put a check on each and every record in JavaScript. – Nick Div Aug 19 '14 at 13:39
  • @kapilchhattani what kind of CMS? – DerZyklop Aug 19 '14 at 13:43
  • you‘ll have to find the place in the shop’s code where the markup is generated. i can‘t imagine another good way to do this. – DerZyklop Aug 19 '14 at 14:01
  • ? Didnt get you... Can you elaborate a bit. – Nick Div Aug 19 '14 at 14:07
  • website basics: there is a browser, that understands html, css and js. and there is a database in the back. and in between, there is a layer that generates the html (markup) with the content from the database. thats where you need to digg in, in order to add a content-related css-class to the html. PS: mark my answer as correct if you didn't find a way to style your content by only touching your sass/css files. – DerZyklop Aug 20 '14 at 14:05
  • 1
    I guess no one has figured out a way to do this. – Nick Div Aug 22 '14 at 09:30