AdamNYC
AdamNYC

Reputation: 20415

Change content of a view depending on iframe size

My Rails app has a page that can be displayed in an iframe of a third-party website. I would like to change the content of my page based on iframe size. (For example, display only 1 element instead of 3, if the iframe size is small).

Is there a way to do this?

Upvotes: 0

Views: 98

Answers (1)

Kombo
Kombo

Reputation: 2381

You'll probably want to take a look at media queries.

The basic idea is something like this:

@media (max-width: 768px) {
  .hide_on_small_screens { display: none; }
}

You can then add this or similar classes to the objects you want to hide/show. Alternatively you can just write the code for say a class like .iframe_wrapper

Upvotes: 2

Related Questions