We're developing a touch screen Qt application in C++ forms that requires a wide down arrow graphic image as well as a custom background. I've been trying to get something that works using QSS, but have thus far been defeated.
The only way I found to get a wide button (one larger than 16 pixels) is to use negative margins:
QComboBox {
min-height:63px;
max-height:63px;
margin-right:47px;
border-image:url(Resources/ComboBox_Center1.png);
font-family: "Franklin Gothic Medium";
font-size: 22px;
}
QComboBox::drop-down {
width:47px;
border:0px;
margin:0px;
margin-right:-47px;
}
QComboBox::down-arrow {
image:url(Resources/ComboBox_Right1.png);
}
This puts the button at the correct position and makes the input area the correct size, but then the down arrow only opens the combobox, not open and then close.
All other options either extend the input area onto the area (margin, border) or shrink the entire control.
Setting the background-image tag had no effect - only the border image showed the image.
Note that the border image (or background color) always shows up even under the arrow.
Is there some way to style just the input section of a combo box? It seems like that portion of the combo should have its own child selector, but I haven't seen it.
Try this...
QComboBox {
min-height:63px;
max-height:63px;
font-family: "Franklin Gothic Medium";
font-size: 22px;
padding: 1px 1px 1px 1px;
}
QComboBox::drop-down {
width: 47px;
border: 0px;
}
QComboBox::down-arrow {
image: url(Resources/ComboBox_Right1.png);
width: 42px;
height: 42px;
}
Note: the width and height on the down-arrow image will depend on the image you are using. These work for my image.
There are some weird things about style-sheets - and a lot of hidden tricks. It might be worthwhile taking a few minutes to go through this which describes the basic principles behind how style sheets work. They seem easy, but even after using them for a while, I often go back to the examples and documentation.
Background images are one of those things that is not obvious. Here is something I took directly from the doc. In most cases when setting an image for the background what we really want is to set the border-image. I'm assuming the reason you don't see the "background-image" is that the combo-box is a "complex" widget - meaning that it is made up of a few others - and so that background is hidden behind them.
It is common to try the background-image property, but this has a
number of drawbacks: For instance, the background will often appear
hidden behind the button decoration, because it is not considered a
background. In addition, if the button is resized, the entire
background will be stretched or tiled, which does not always look
good. It is better to use the border-image property, as it will always
display the image, regardless of the background (you can combine it
with a background if it has alpha values in it), and it has special
settings to deal with button resizing.
As for styling the input area... assuming your QComboBox is editable, the input area is just a QLineEdit. So you could always assign a style sheet to the line edit this way
comboBox->lineEdit()->setStyleSheet(your style sheet);
I hope that helps.
Related
I've added a new link to my navigation bar, and for more visibility, have added a "New" marker to this link for improved visibility. This "New" marker is 0.8rem compared to the link's text being 1rem. I mention this because if the "New" marker is changed to be 1rem, then this issue does not occur.
The issue itself:
When hovering over the "Order Now" link (see Codepen), you might notice that the container height is stretched by maybe a pixel or 2 from the bottom - it's somewhat hard to see in this example but tried to make the colours as obvious as possible. It's most obvious when looking at the blue underline that there is a small gap between the active link (About us) and the hovered link. This only happens when hovering over "Order Now", and as mentioned, is rectified when setting the font size of "New" to 1rem (or removing "New" completely)
Codepen with minimum example: https://codepen.io/ftahir192/pen/PoPXjEv
This is the css for the "New" marker:
.new-marker {
color: red;
font-size: 0.8rem;
}
There's nothing special going on with that aside from the differing font size. I've tried:
Setting absolute positions on the container
Setting relative positions on the links itself
Playing with line-height - this fixes it but seems more of a hack.
It's a minor nuisance but still a nuisance nonetheless and something I haven't been able to get to the bottom of. Any tips would be very much appreciated
You can fix that by adding line-height its not a hack, the <i> tag inherits the <a> tag line-height attribute value (which is 60px), line height will fix it for you:
.new-marker {
color: red;
font-size: 0.8rem;
line-height:1rem;
}
setting the min-height:70px is the reason for this issue. My suggestion is you should change to height: 91px or any other hardcoded value. and avoid using min-height.
I am creating a blog, and on the top of the blog is an image of some scene (I used a picture of NYC) with the text of the most recent blog post over top of it. I thought it would be really cool to have the letters have an outline, but can still be transparent so the viewer can still see the image.
I tried text-shadow with a transparent color, but all I got was a black letter (which I didn't expect but makes sense). I ended up using the webkit-text-stroke property, which isn't cross browser at all. I've attached an image of it in both Chrome and Firefox, with a text shadow behind it so you can see how a text shadow appears (kind of) without a color present.
Is there a way to have the desired effect (a border around the text, but no color) in modern browsers? For IE9 and down I'll just use a solid black color so.
This is the code I'm using to get the below effect:
figcaption {
position: absolute;
bottom: 0px;
left: 20px;
font-size: 90px;
color: transparent;
-webkit-text-stroke-width: 5px;
-webkit-text-stroke-color: #1F1F1F;
text-shadow: 1px 1px 5px rgba(255, 255, 255, 0.5);}
Thank you.
A couple of thoughts.
This example isn't exactly what you have described, but the result is good and should work well cross-browser:
http://jsfiddle.net/panchroma/JHvgp/
The key CSS is
h1.figcaption {
color:white;
position: absolute;
bottom: 0px;
left: 20px;
font-size: 90px;
opacity: 0.35;
filter: alpha(opacity=35);
text-shadow: 2px 2px 2px #000;
}
Alternatively, maybe it's possible to do something with with sIFR ... not sure about this though.
Good luck!
EDIT
Good suggestion from Adrien Be below -- with improved cross-browser transparency code:
http://css-tricks.com/snippets/css/cross-browser-opacity/
[I have no real ready-to-use solution here; but my thoughts on this are getting too long for a comment, so excuse me for putting this here.]
Cross-browser that’s kinda hard to achieve. I’ve looked into ways to get this kind of effect as well (and wasn’t satisfied with having it work webkit-only), and I came up with stuff like using dynamically created Canvas or SVG images that I draw the text on and then manipulating alpha values (canvas) or applying mask/filter effects (SVG).
But it’s a bit of a challenge to get the font rendering/positioning exactly right, and when text has to flow over multiple lines it gets even more complex. Best way I found for that is to split up the text into multiple span elements, one for each word; and then I place a Canvas or SVG image containing just that word as a background image for the span element. Big advantage here: The browser still takes care of text flow, like where to break text into a new line etc., because that’s a bit of a hassle to implement yourself in Canvas or SVG. And text flow also automatically adapts if the area the text gets displayed in changes size (f.e. user resizing browser window). What needs a little extra care is handling text resizing after the effect is applied – when user changes font size in their browser, the text I painted on my image might not fit any more – although using SVG and relative units that can be handled quite automatically as well. The other workarounds are either using background-size to scale the background image to the size of the span containing the word, or somehow capture that resize-“event” and re-draw images dynamically.
Using background images has the advantage that I can still keep the original HTML text in place – just setting it to transparent, so that when the user f.e. starts selecting text on the page it will still show up as actual text and is copy&paste-able.
But for a small effect like this it’s quite a lot of work … so I decided in the end to give up on that, and postponed using “transparent letters” until browser support for easier solutions like the webkit one you mentioned gets wider.
When using the like or send widget on a Fan Page (no mater if you use iframe tag or fbml for it) the overlay for commenting is positioned always to the right. see
http://twitpic.com/4q7ggi for example.
I cant find a way to get the widget to respect the 520px boundary of the facebook tab.
see http://www.facebook.com/pages/Ludwig-Test/127771653944246?sk=app_101150316644842 for an example.
Anyone an idea how to solve this ?
TIA
Rufinus
Try adding this to your css:
.fb_edge_comment_widget {
margin-left: -350px;
}
This will move comment box to the left, but the little arrow pointing to the button will move too (which you could try to cover with another element). It will only work if you're using XFBML, not an iframe.
Here's an example.
I had to move the little arrow to the bottom, and that's how i did it.
1) Move your popup window to the desired position. Use the !important statement to overwrite default styles.
.fb_edge_comment_widget {
top: -224px !important; left: -246px !important; height: 191px;
background: url(../img/arrow-down.gif) 0 100% no-repeat
}
This style also contains a new arrow image which replaces the bottom line of the popup window. It contains my own new bottom arrow, which is blue (#283E6C) by default and grey inside (#F2F2F2). We can use height to adjust the vertical position and move the background image to the bottom.
The image will look like this:
.
2) Apply overflow: hidden to the span that wraps the iframe, We'll be able to cut off parts of the iframe by applying margin-top in step 3, and replace them with our own.
.fb_edge_comment_widget > span {
height: 184px !important; overflow: hidden; border-top: 1px solid #000;
}
I'm using border-top to create my own upper border, since in step 3 we are cutting of the default border and arrow.
3) Move the iframe up a bit to cut off its upper border and arrow.
.fb_edge_comment_widget > span > iframe {
margin-top: -7px;
}
The result looks like this in my case:
If you're using the XFBML implementation of the Facebook Like button, you can use CSS to re-position the "flyout" menu relative to its original position near the Send button:
The above example using jsFiddle and this CSS:
.fb_edge_comment_widget {
margin-left: -343px;
}
Since the contents of the "flyout" are inside an iframe you won't be able to apply any CSS to it — meaning, moving the triangle indicator to the right side of the "flyout" isn't possible.
Web browsers have tightened security on cross-frame scripting due to spoofing and other hacks, so iframes are treated like separate HTML pages with their own CSS and JavaScript.
For any advanced CSS styling, you would have to inject the Facebook Widget's iframe using DOM Scripting ... and even then it may not work across browsers.
Not a great answer but the only option I have found is to wrap the widget in an absolutely positioned Div to keep it on the left side of the window
To fix it I strongly recommend to put the Facebook widget on the left side of your page. Any other solution could work for a certain period of time, but in the future will fail.
The reason is that Facebook updates its widget frequently.
How can I do to have an image as the background for all links? I want to have a nice box representing buttons, but I cannot figure this out.
I have tried:
a {
font-size: 40px;
background: url('images/shooting-stars/shooting-star-link.png') no-repeat left top;
}
But this is not working, image is not displaying.
"I want to have a nice box representing buttons, but I cannot figure this out." - I don't understand this part.
Anyway, your css looks fine from here, are you sure the image exists? This is a working example with the exact same code, just an image that I'm sure exists:
http://jsfiddle.net/3k9nm/
If you want to always show the image, even if the text is shorter, you should set a minimum width for the links. This does mean they'll have to be inline-blocks, you can't set width on a regular link (which is an inline element).
a {
display: inline-block;
min-width: 25px;
}
(25px was randomly chosen, fill in the width of your background image..)
Two things to try, is there any text in the actual <a> links? And if you use Firebug, you can check you've definitely got the right file path to the image...
HTML
<div id="example-link">
Link to journal article
</div>
CSS
#example-link a {
background: url('images/shooting-stars/shooting-star-link.png');
}
I am working on a site that uses three small images as links to twitter, facebook, etc. I have a callout image that I would like to appear when I mouse over the image.
The key here is that the callout image not interfere with the other images and text on the page.
Is there a handy solution that would meet this need?
not positive but it sounds like u can just assign the background image and use the background-position property to show the appropriate image during hover and non-hover state
a.twitter { display: block; width: 16px; height: 16px;
background: url(/images/twitter-hover.png) no-repeat 0 0; }
a.twitter:hover { background-position: 0 16px }
that's assuming a 16x32 sprite comprised of two 16x16 buttons (non-hover and hover) stacked vertically.
this is a rudimentary example http://www.dynamicsitesolutions.com/css/background-image-switching/
Old skool:
Combine the images into one and then use a client side imagemap with onmouseover events which make the appropriate divs visible.
New skool:
Use CSS hover psuedo class. Good example here: http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer/ (won't work in all browsers)
Have you tried MooTools? They have a lot of Javascript utilities that might meet your requirements.