Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scaling large image to fit screen width using angular

I would like to scale a large image's height/width using AngularJS so that it fits the screen on multiple devices (responsive). This website is an example of what I am trying to accomplish.

Does angular have a directive that can handle this or will I need to create a directive or factory to accomplish this task? Has anyone tried WURFL Image Tailor (WIT)?

like image 367
user3574939 Avatar asked Oct 31 '25 20:10

user3574939


1 Answers

In most cases, you don't need angularjs at all. This can be accomplished with css alone, using the background-size property.

For example, in order to scale to width:

.bg {
  background-size: 100% auto;
}

and to scale to height:

.bg {
  background-size: auto 100%;
}
like image 190
Moshe Shaham Avatar answered Nov 02 '25 10:11

Moshe Shaham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!