Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Support for max-width #1334

Open
TheCarpetMerchant opened this issue Jul 1, 2023 · 4 comments
Open

[FEATURE] Support for max-width #1334

TheCarpetMerchant opened this issue Jul 1, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@TheCarpetMerchant
Copy link

It would be nice to have support for max-width:100%, so that images that have a set width don't get rendered bigger then the screen.

Code I used to test things out :

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: Html(
          data: '<img style="width:800px;max-width:5%" src="https://cdn.discordapp.com/attachments/840351500010258474/968560163382521946/2022-03-31_14-16-27_0503.jpg"/>',
        ),
      ),
    ),
  );
}
@TheCarpetMerchant TheCarpetMerchant added the enhancement New feature or request label Jul 1, 2023
@Mohamed-Aziz-Mhadhbi
Copy link

You can also add SingleChildScrollView widget to ensure the content can scroll if it exceeds the screen height.

The updated code :

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: Html(
            data: '''
              <style>
                img {
                  width: 800px;
                  max-width: 100%;
                }
              </style>
              <img src="https://cdn.discordapp.com/attachments/840351500010258474/968560163382521946/2022-03-31_14-16-27_0503.jpg"/>
            ''',
          ),
        ),
      ),
    ),
  );
}

@TheCarpetMerchant
Copy link
Author

@Mohamed-Aziz-Mhadhbi This is an issue about width, not height...

@thanhle7
Copy link

It would be nice to have support for max-width:100%, so that images that have a set width don't get rendered bigger then the screen.

Code I used to test things out :

import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: Html(
          data: '<img style="width:800px;max-width:5%" src="https://cdn.discordapp.com/attachments/840351500010258474/968560163382521946/2022-03-31_14-16-27_0503.jpg"/>',
        ),
      ),
    ),
  );
}

I am 2nd for that

@TheCarpetMerchant
Copy link
Author

See #1359.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants