# CSS calc and media query

**URL:** <https://community.hubspot.com/t/css-calc-and-media-query/20396>\
**Category:** CMS Development\
**Tags:** css\
**Created:** [April 27, 2020, 1:35pm UTC](https://community.hubspot.com/t/css-calc-and-media-query/20396 "2020-04-27T13:35:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oloph](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oloph/32/44643_2.png) [@Oloph](https://community.hubspot.com/u/Oloph)\
**Post date:** [April 27, 2020, 1:35pm UTC](https://community.hubspot.com/t/css-calc-and-media-query/20396/1 "2020-04-27T13:35:20Z")

</div>

Hello community!

I’m trying to build a reponsive module with dynamic container widths using width: calc(). It works fine inline calling the loop.length function.

```auto
 {% for item in module.highlight_box %}
 <div class="highlight" style="width: calc(90%/{{ loop.length }})">

```

However, I’d like it to kick in only in desktop mode, with a media query.

The problem is

- Media query won’t render the calc() expression
- I can´t access loop.length in the module css.

Ideas on how to solve this is much appreciated!

Best regards/Selftaught noob

---

<div class="post-metadata">

**Author:** ![stefen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefen/32/29274_2.png) [@stefen](https://community.hubspot.com/u/stefen)\
**Post date:** [April 27, 2020, 7:09pm UTC](https://community.hubspot.com/t/css-calc-and-media-query/20396/2 "2020-04-27T19:09:05Z")

</div>

@Oloph you can use the [{% require\_css %}](https://designers.hubspot.com/docs/hubl/tags#require-css) tag inside the HTML area if you have to have HubL in your styles.

---

<div class="post-metadata">

**Author:** ![Oloph](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oloph/32/44643_2.png) [@Oloph](https://community.hubspot.com/u/Oloph)\
**Post date:** [April 28, 2020, 11:03am UTC](https://community.hubspot.com/t/css-calc-and-media-query/20396/3 "2020-04-28T11:03:28Z")

</div>

Thanks Stefen

Wouldn’t that be just moving the styling from inline to the head, or what am I missing?

Is there a Hubl function to get the screen size? That way I coud put it in a {% if [screensize \> x] %} sort of statement.

Thanks!

---

<div class="post-metadata">

**Author:** ![Oloph](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oloph/32/44643_2.png) [@Oloph](https://community.hubspot.com/u/Oloph)\
**Post date:** [April 29, 2020, 7:38am UTC](https://community.hubspot.com/t/css-calc-and-media-query/20396/4 "2020-04-29T07:38:19Z")

</div>

Hi again

It turns out this was all easily achieved with flexbox. No need to involve loop length to set column width.

Sorry about the trouble!
