css 可以按比例缩放图片吗?

html-css07

css 可以按比例缩放图片吗?,第1张

解决这个问题的方法如下:

1、先在html里添加一个img图片标签。

2、运行页面后,这是完整显示图片大小的。图片大概是400x260左右的大小。

3、要进入图片缩放,可以在css样式里设置图片的宽度和高度,但不要宽和高都设置了,比如这里都设置为100px。

4、设置后,看下页面可以看到图片现在变形了。

5、正确的方法应该是只设置其中一个,比如设置宽度为100px,高度设置为自动就行了。

6、这里设置后的效果,图片并没有变形。

7、同样,如果是限定高度的大小,就设置宽度为自动,图片同样不会变形,这样问题就解决了。

需要准备的材料分别有:电脑、chrome浏览器、html编辑器。

1、首先,打开html编辑器,新建一个html文件,例如:index.html。

2、其次,在index.html中的<style>标签中,输入css样式代码:body {background: url(image7.jpg) no-repeatbackground-size: 250px}。

3、最后,浏览器运行index.html页面,此时用CSS强制了图片占用250px宽度的大小并且是等比例自动缩放。

css怎么让div的高度随着宽度按比例缩放

常用的方法是通过背景图示的cover属性让div的高度随着宽度按比例缩放

#banner .bd li {

width: 100%

background-repeat:

no-repeat

background-size: cover

background-position: center

0

background-position: 50% 50%

-webkit-background-size:

100%

padding-: 42%

}

C#怎么让控制元件随窗体按比例缩放?

你可否换个事件写缩放程式码?放到载入里面去

cad家俱怎么按比例缩放

操作步骤如下:

命令: sc

SCALE

选择物件: 指定对角点: 找到 1 个

选择物件:

指定基点:

指定比例因子或 [复制(C)/参照(R)]: 2 (比例)

如何按比例缩放UIImageView

CAXA比例是非常方便的,你可以直接输入号码,你可以输入一个表示式,如取两件事情的长度扩大到5,输入比例因子:5/2,就可以了,这种方法并不特别适合知识这种情况放大系数。

按比例缩放需要用程式来完成,可以参照下面的程式:

@interface HYShowImageView : UIScrollView <UIScrollViewDelegate>

显示影象大图

-(void)showImage:(UIImage*)image inView:(UIView *)parentsView fromRect:(CGRect)rect

@end

-(void)showImage:(UIImage*)image inView:(UIView *)parentsView fromRect:(CGRect)rect

{

_oldRect = rect

[self setFrame:CGRectMake(0, 0, PHOTOWIDTH, PHOTOHEIGHT)]

self.showsHorizontalScrollIndicator = NO

self.showsVerticalScrollIndicator = NO

UIImageView *showView = [[UIImageView alloc] initWithFrame:_oldRect]

showView.contentMode = UIViewContentModeScaleAspectFit

[UIView animateWithDuration:0.5f animations:^{

[showView setFrame:CGRectMake(0, 0, PHOTOWIDTH, PHOTOHEIGHT)]

}]

[self setBackgroundColor:color_with_rgba(0, 0, 0, 1)]

[parentsView addSubview:self]

[showView setTag:'show']

[showView setImage:image]这个地方也可以用网路的图片

[self addSubview:showView]

增加两个手势

showView.userInteractionEnabled = YES

UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleViewTap:)]

[self addGestureRecognizer:singleTap]

UIPinchGestureRecognizer* pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchView:)]

[self addGestureRecognizer:pinchGesture]

}

增加了两个手势,一个点选取消,一个缩放

移除图片检视检视

-(void)handleSingleViewTap:(UITapGestureRecognizer *)sender

{

[self setZoomScale:1.0 animated:NO]

[UIView animateWithDuration:0.5f animations:^{

UIImageView *showView = (UIImageView *)[self viewWithTag:'show']

showView.frame = _oldRect

self.backgroundColor = color_with_rgba(0, 0, 0, 0.0)

} pletion:^(BOOL finished){

[self removeFromSuperview]

}]

}

缩放图片

-(void)handlePinchView:(UIPinchGestureRecognizer *)sender

{

UIImageView *imageView = (UIImageView *)[self viewWithTag:'show']

if ([sender state] == UIGestureRecognizerStateBegan) {

_imageHWScale = imageView.image.size.height/imageView.image.size.width

_beganScale = self.zoomScale

}

[self setZoomScale:_beganScale * sender.scale]

if ([sender state] == UIGestureRecognizerStateEnded) {

[self scrollViewEnd]

}

}

- (void)scrollViewEnd

{

if (self.zoomScale <1.0) {

[self setZoomScale:1.0 animated:YES]

self.contentOffset = CGPointMake(0, 0)

} else if (self.zoomScale >3.0) {

[self setZoomScale:3.0 animated:YES]

}

}

把UIImageView放到UIScrollView中,将UIScrollViewDelegate中的- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView方法return这个imageView

js实现div盒子宽度和高度成比例缩放怎么写

说一下思路:

等比例  就是要找出宽高的比。如果100/80

然后在缩放时,先缩放一个,然后用已知的宽高比算另一个值。