CSS Background image not showing with height auto - height

I have a div with a background image in it. I have to specify a height in px for it to show. But I want it to show with height auto as the width resizes. I am stuck.
When I have height auto it just does not show the image at all...
#slider-shadow1 {
z-index: 9999;
margin: 0 auto;
width: 100%;
height: auto;
background: url(images/layouts/shadow2.png) center no-repeat;
background-size: 100% 100%;
position:relative;
display: inline-block;
background-size:cover;
overflow: hidden;
}

Height: auto means the height of element is exactly the same as elements content. If you have empty element, its height is zero. And you can't see background image (you see exactly 0px of them).

Related

C++ Resize QScrollBar up-arrow

auto bar = ui->verticalScrollBar();
bar->setStyleSheet("QScrollBar:vertical { width: 20px; }"
"QScrollBar::up-arrow:vertical, QScrollbar::down-arrow:vertical { width: 15px; height: 15px; }");
I cannot resize the arrows. scrollbar
Already checked stylesheet example here http://doc.qt.io/qt-5.6/stylesheet-examples.html
Any idea would be appreciated.
Try to use min-width, max-width (the same value), min-height, max-height (the same value) instead of width and height.

How to get a QProgressBar in QT with rounded edges and rounded progress edges?

I have created a vertical progress bar and an trying to style it with rounded edges. No matter what I do, I don't seem to be able to get the progress or chunk of the progress bar (QProgressBar::chunk) with rounded edges. Please help me out, I am new to QT.
Please find my code below:-
progressbar_V = new QProgressBar;
progressbar_V->setParent(this);
progressbar_V->setMinimum(0);
progressbar_V->setMaximum(5);
progressbar_V->setValue(3);
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");
progressbar_V->setGeometry(250,250,60,300);
progressbar_V->setOrientation(Qt::Vertical);
The Progress Bar text is at the top in the output as well. How will I get it to the middle of the vertical progress bar
You're right, you can use this parameter:
border-radius: 50px;
to get round borders !
but you just forgotten to specify px at the end
So, once your code is updated, it looks like this :
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey; border-width: 6; border-radius: 12px; color: black; text-align: centre; margin-right: 12; }, QProgressBar::chunk:vertical {background-color: #05B8CC; width: 20px;}");
You need to change your style sheet into something like this:
progressbar_V->setStyleSheet("QProgressBar{ border: solid grey;border-bottom-right-radius: 12px;border-bottom-left-radius: 12px; color: black; text-align: centre; },QProgressBar::chunk {background-color: #05B8CC;border-bottom-right-radius: 7px;border-bottom-left-radius: 7px;}");
happy coding..

Susy gallery breaks height for display table and table-cell

I'm trying to get equal height columns on my responsive grid using the gallery mixin for SUSY. To do that, I set the container "display: table" and the column "display: table-cell". This works for me if I do not use the mixin, but fails as soon as I turn on the mixin. The mixin works if I have set the height in pixels, but not if I set the height using 100%;
I'm using:
susy (2.1.3) and
sass (~> 3.3)
This works with or without SUSY:
.ttable {
#include container;
padding: gutter();
#include clearfix;
.ttd {
#include gallery(3 of 12);
}
}
.ttable {
display: table;
height: 500px;
border: 1px solid #BF0D3E;;
}
.ttd {
display: table-cell;
background-color: #eee;
height: 500px;
}
This doesn't work with SUSY, but works with the mixin turned off:
.ttable {
display: table;
height: 100%;
border: 1px solid $fuschia;
}
.ttd {
display: table-cell;
background-color: #eee;
height: 100%;
}
The gallery mixin uses floats and margins to position elements, which won't work with table display. The first one works because the table styles are ignored, and the items are floated with a set height. If you want to use table styles to get equal-heights, you should leave out the gallery mixin, and use individual mixins/functions to set width/gutters instead (I think only inside and inside-static gutters will work with table display).
.ttd {
#include gutters;
display: table-cell;
background-color: #eee;
width: span(3 of 12);
}

CSS3 circle with gradient border?

I am trying to replicate a green square image in pure css3. You can see the image here:
So far I have managed to generate the square, looking just like the one in the image. The problem is the border of the circle in the square. As you can see, the border of that circle in the image is gradient and mine is not (see fiddle) and I have no idea how to replicate this in CSS...
Here is my fiddle of the square
The CSS code I am currently using:
.greenBlock, .greenCore {
background-color: #00c200;
border: 3px solid;
border-top-color: #00de00;
border-right-color: #006900;
border-bottom-color: #006900;
border-left-color: #00de00;
z-index: 10;
width: 42px;
height: 42px;
}
.greenCore {
width: 22px;
height: 22px;
border-radius: 50%;
-webkit-transform: translate(25%, 25%);
transform: translate(25%, 25%);
}
How can I do this gradient circle border in CSS3?
Thanks a lot
I would use a pseudo-element (:before) and style it with a gradient background.
(that is because border-image cannot be combined with border-radius)
.greenBlock {
background-color: #00c200;
border: 3px solid;
border-top-color: #00de00;
border-right-color: #006900;
border-bottom-color: #006900;
border-left-color: #00de00;
width: 42px;
height: 42px;
position:relative;
z-index:10;
}
.greenCore {
background-color: #00c200;
width: 22px;
height: 22px;
border-radius: 50%;
top:50%;
left:50%;
margin-left:-11px; /*half width*/
margin-top:-11px;
position:relative;
}
.greenCore:before{
content:'';
position:absolute;
z-index:-1;
border-radius:50%;
width:28px; /*22 of greenCore + 3 + 3 for the borders*/
height:28px;
left:-3px;
top:-3px;
background: -moz-linear-gradient(-45deg, #00ff00 0%, #004900 100%);
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%,#00ff00), color-stop(100%,#004900));
background: -webkit-linear-gradient(-45deg, #00ff00 0%,#004900 100%);
background: -o-linear-gradient(-45deg, #00ff00 0%,#004900 100%);
background: -ms-linear-gradient(-45deg, #00ff00 0%,#004900 100%);
background: linear-gradient(135deg, #00ff00 0%,#004900 100%);
}
<div class="palette greenBlock" data-code="2">
<div class="greenCore"></div>
</div>
One possibility is to make a slightly larger circle with a diagonal gradient background, and place it behind the "core"-circle. This way the larger circle will appear to be a border to the second circle. By modifying your fiddle, I got something like this.
In order to make the gradient I used the linear-gradient function, and assigned it as the background:
background: linear-gradient(135deg, #00de00, #006900);
The first value is the direction of the gradient in degrees. The second two values is the start and end color of the gradient.
Perhaps you can try adding this:
box-shadow:1px 1px 3px 1px #000, -1px -1px 1px #fff;
-moz-box-shadow:1px 1px 3px 1px #000, -1px -1px 1px #fff;
-webkit-box-shadow:1px 1px 3px 1px #000, -1px -1px 1px #fff;
To your .greenCore class. This may be close. You may want to play with the values to get it closer to your liking.

Make QGroupBox::title expand

Using a stylesheet I manage to set the background for the title element as shown in the image above (1.) using:
QGroupBox::title
{
background-color: rgb(255, 255, 0);
subcontrol-origin: margin;
subcontrol-position: bottom center;
}
Now I want the title to expand to the maximum size of the hosting QGroupBox as shown in image 2.. How do I accomplish this?
Thanks!
Edit: I wish to do this using style sheets only.
It turns out my efforts to find a solution on Google failed due to incorrect search terms...
http://www.qtcentre.org/threads/43232-customizing-QGroupbox-title purposed setting
QGroupBox::title
{
padding-left: 2000px;
padding-right: 2000px;
}
Not very pretty but at least It could be done using stylesheets only.
You can set background-image to expand the title.
QGroupBox {
border: 1px solid #90c6dd;
border-radius: 0px;
margin: 8px 8px 7px 7px;
padding: 56px 10px 10px 10px;
background-image: url(:/res/svg/group-bg.svg);
background-repeat: repeat-x;
background-position: top left;
}
QGroupBox::title {
font-size: 24px;
font-weight: bold;
subcontrol-origin: padding;
subcontrol-position: top left;
min-height: 39px;
padding: 0 10px 0 10px;
}
if you can get pointer on the QGroupBox parent you can get its width and knowing its parameter do the following:
this->setWidth(pOnParent->width());
padding-left: 100%;
padding-right: 100%;