Can anyone help me resize images?
Added by Matt Picas about 9 years ago
Hi Everyone, I finally got Wt working but am having trouble resizing the images to fit the browser. I want to use 4 images across the screen at 448x280 pixels each and it looks great on a 1920x1080p monitor in full screen on a browser, but everything else it is displaying badly with the pictures out of place (If I reduce the browser size it does this.) I found this video on how to resize images in CSS (https://www.youtube.com/watch?v=DvIOex3BhD8) and tried to edit the dragdrop.CSS file for the dragdrop example to resize the images that I added to this container:
DragExample::DragExample(WContainerWidget *parent):
WContainerWidget(parent)
Here is an example of one of the images I added to that container:
WImage *MyTestPic = new WImage(WLink("icons/MyTestPic.jpg"), this);
MyTestPic->setMargin(5, Left);
So that loaded the image onto the page so to try to fix the resizing I went into the CSS and added the following line of code for that image (and each of the other ones):
.MyTestPic {
max-width: 90%;
max-height: 90%
}
I was hoping it would work and recognize my MyTestPic WImage widget and fix it like it did in the guys video but it didn't. Can anyone help me? I'd be very grateful and appreciate it so much!
Replies (1)
RE: Can anyone help me resize images? - Added by Christian Meyer about 9 years ago
Have you added a style class to the image?
like:
MyTestPic->setStyleClass("MyTestPic");
also you need to specify to use the style sheet you defined:
@
Wt::WApplication *app = Wt::WApplication::instance();
app->useStyleSheet(Wt::WLink());
@