Using not: to select all imgs with a default width? - css

I have been bashing my head against this for a while. I'm a fairly huge novice when it to this so thought it was time to ask for help.
Trying to select all imgs on a page that are set at their default value (unclear if this is auto or initial, because it seems auto is applied by default and the console only shows width with nothing else after) and apply a size to them.
I want this to exclude imgs that I have manually set the size of.
So far I have tried this for my CSS, but it doesn't seem to work.
img:not([width:initial]){
width: 400px;
}
HTML SECTION OF PAGE WITH IMAGE:
<div class="internal-embed image-embed is-loaded" tabindex="-1"
src="TeniaeColiHisto.png" alt="TeniaeColiHisto.png" width=""
height="" contenteditable="false"><img width="" src="app://local
/D%3A%5CSecondBrain%5CImages%5CTeniaeColiHisto.png?1642441174361"
alt="TeniaeColiHisto.png" height=""></div>
<img width=""
src="app://local/D%3A%5CSecondBrain%5CImages%5CTeniaeColiHisto.png?1642441174361"
alt="TeniaeColiHisto.png" height="">
Edit: Made some headway with:
img[width]
{
width: 400px;
}
It seems I would solve my issue if the following would work but for some reason it doesn't?
img[width]not:([width=""])
{
width: 400px;
}
EDIT SOLUTION:
Turns out the program i'm using doesn't actually automatically set the width of the images. It just inherits them from the source and the actual HTML includes no width or height tag.Thus, the solution was to specify all images that did not these attributes as such.
img:not([width])
{
width:400px;
}

Related

Css print : page margin conflicts with fixed title

I am looking for a way to set a print-devoted css that shows a fixed title on every page.
Unfortunately, I couldn't manage to print this title nicely on the 2nd page, since it always "walks on " the table, ignoring declared body padding / margin ... though I am quite sure the body is not suited here, I couldn't find any working way.
Any idea?
<h2 id="tableTitle">Fixed title</h2>
<button class="noPrint" onclick="myFunction()">Print this table</button>
<table>...content fitting at least 2 pages ...</table>
...
body{
margin-top:100px;
}
#tableTitle {
position: fixed;
top : 0;
}
Here's the fiddle

PrimeFaces p:selectOneMenu width

I want p:selectOneMenu width to be auto regarding to the parent cell not regarding to the values it has.
<p:panelGrid>
<p:row>
<p:column><p:outputLabel value="Value01" for="idInput01"/></p:column>
<p:column><p:inputText value="#{bean.input01}" id="idInput01" /></p:column>
<p:column><p:outputLabel value="Value02" for="idSelect" /></p:column>
<p:column>
<p:selectOneMenu value="#{bean.selectedObject}" id="idSelect" converter="objectConverter">
<f:selectItems value="#{bean.objectsList}" var="varObject" itemLabel="#{varObject.label}" itemValue="#{varObject}" />
</p:selectOneMenu>
</p:column>
</p:row>
</p:panelGrid>
What I've got :
What I'm expecting :
Note: I don't want to specify a fixed width.
My solution: autoWidth="false"
i overrode .ui-selectonemenu, .ui-selectonemenu-label to:
.ui-selectonemenu{
width: 100% !important;
}
.ui-selectonemenu-label{
width: 100% !important;
}
The only way I found is to use jQuery to initialize width at load time.
You can create simply a CSS class like this (just to be used as a futur selector) :
.full-width
{
}
And add it to your component :
<p:selectOneMenu value="#{bean.selectedObject}" id="idSelect" converter="objectConverter" styleClass="full-width">
<f:selectItems value="#{bean.objectsList}" var="varObject" itemLabel="{varObject.label}" itemValue="#{varObject}" />
</p:selectOneMenu>
Since you will need jQuery, you should add this inside your h:head if you are not already using PrimeFaces components that use it.
<h:outputScript library="primefaces" name="jquery/jquery.js" />
Here is the small script that initialize all p:selectOneMenu in the selector :
<script>
$(document).ready(
function()
{
$("div.ui-selectonemenu.full-width").each(
function()
{
$(this).css("width",$(this).parent().width());
}
);
}
);
</script>
you can add the value of width directly in the component to modify it, to avoid impacting other p: selectOneMenu existing in the page.
<p:selectOneMenu style="width: 100% !important">
...
</p:selectOneMenu>
I now have a proper fix for this.
Primefaces 6.0 now has a new field called autoWidth that by default is set to true, and you can set to false.
IF you do as some of the above responses say and set it to false, all you are doing is playing roulette with you app css.
By setting it to false, primefaces will leave it up to you to manage the width.
You can either have the width set on the selectOneMeny expliclitly by style attribute, or some css class in your application.
But this is not what this issue is about, this issue is about the fact that the default behaivor of not specifying any width to a drop down makes leads our drop downs to normally be way too small for the labels in there.
So what we actually want is for the autoWidth to work proplerly.
FInally, I looked at the component and at the renderer, and it is obvious the auto-width mechanism does not work in the backend side.
The backend side only builds some JSON like data that the primefaces javascript builder can use to properly tune on the browser the behavior of the widget.
If you loook at primefaces 6.0 source code, the bug is in META-INF\resources\primefaces\forms
Search for the code that says the following:
PrimeFaces SelectOneMenu Widget
In this javascript function hunt for the code chunk that says:
_render: function() {
if(this.cfg.autoWidth) {
In this section of code your bug is the following line:
this.jq.css('min-width', this.input.outerWidth());
Here, I applied the following patch that hopefully should work in geting the drop down box to be as fat as the largest label:
_render: function() {
if(this.cfg.autoWidth) {
// BEGIN: PATCHING
// ORIGINAL CODE:
// this.jq.css('min-width', this.input.outerWidth());
// BUGFIX:
// (a) compute the original min-with primefaces 6.0 would put on the root div
var primefacesBugWidth = this.input.outerWidth();
// (b) compute the length of the hidden select element with all the labels inside of it
var widthOfHiddenDivWithSelectLabels = this.jq.find('div select').width();
var widthOfTheDropDownTriangle = this.jq.find('.ui-selectonemenu-trigger.ui-state-default.ui-corner-right').width();
var widthOfLabelPlusTraingle = widthOfHiddenDivWithSelectLabels + widthOfTheDropDownTriangle;
// (c) we will use whichever length is longer
// in bug-fixed primefaces version the outerWidth should be computed correctly
// but this seems not to be the case
var maxWidthOfTwoPossibleOptions = primefacesBugWidth > widthOfLabelPlusTraingle ? primefacesBugWidth : widthOfLabelPlusTraingle;
this.jq.css('min-width', maxWidthOfTwoPossibleOptions);
// END: PATCHING
}
}
The idea of the code above is:
(a) look at the hidden div with all labels and get the width of that div
(b) add to that length the width needed for the primefaces triangle facing down
(c) compare the width we have computed to that that is suggested by primefaces and that seems to be way too small
NOTE:
To install the patch you have to copy all of the Primaces code for the SelectOneWidget.
Add it to a javascript file under your control.
Make sure you only run the compilation of your javascript file after the primefaces javascript file has been loaded.
Normally primefaces is being rendered at the HEAD.
So if you have you jasvacript as the last ement in the body you should be fine.
The patching is working fine for me.
THis is code I do not like to maintain however.
You can ID the element and change the style width through CSS. Make it 100% of its container.
If your p:selectOneMenu is in a DIV with an assigned width, I find setting style="width:100%;" on the p:selectOneMenu seems to work in my case.
The problem might be min-width, which is set in the rendered HTML. If that is your case, use a CSS selector fixed-width like this:
<p:selectOneMenu styleClass="fixed-width" ...
then define CSS
.fixed-width { min-width: 100% !important; }
That sets the width of the selectOneMenu widget to the width of the parent element. To have it work, parent elements's width should not be 'auto'.
Those who still got problem with selectonemenu may try this
.ui-selectonemenu {
min-width: 0 !important;
}
Perfectly worked for me.
You can use something like
style="min-width: 12rem"

change image link when hover the link css

I have this link :
</td>
and I want to change the image when the user over the link I tested :
#planification:hover{
background-image:"images_cartographie/cartographie3_03.gif";
}
but the image doesn't change, it is ignored, (I tested background-color it works (then the problem isn't in url or ...))
when I use the background-image without hover like that :
it doesn't appear :
#planification{
background-image:"images_cartographie/cartographie3_03.gif";
}
NB : I generated the page with photoshop
do you have any idea
You can completely remove the img because you add the efect via CSS on the a tag.
HTML
CSS
.image_link{
display:block;
width:800px;
height:600px;
background:url('http://ferringtonpost.com/wp-content/uploads/2012/07/Responsibilities-of-Owning-a-New-Puppy-Photo-by-bestdogsforkids.jpg');
}
.image_link:hover {
display:block;
width:800px;
height:600px;
background:url('http://25.media.tumblr.com/tumblr_m4frqhdW0k1rwpusuo1_1280.jpg');
}
JSFiddle.
Note that you must add dispay:block/inline-block to the a
I'm a little confused about your question, but it sounds like you need to put in two different images. So, there's one image when you mouse over, and another image when you don't. You just put in a different path for the background-url on hover. Also, you should put in a plank gif in your img tag for backwards compatibility.
You should also use a self closing tag /> for your image. The tag is open the way that you posted it.
#planification
{
background: url(images_cartographie/cartographie3_03.gif)
}
#planification:hover
{
background: url(images_cartographie/new_image_goes_here.gif)
}
<a id="planification" href = "" ><img src="images_cartographie/blank.gif" width="207" height="47" alt=""/></a>

How to set up twitter's embedded timeline width in percentage (responsive/fluid design)

I'm looking to set up twitter's embedded timeline, it's quite easy when you're having a fixed design, but that's not my case and I'm actually building a fluid and responsive design for a new website.
My question is, how can I set up twitter's embedded timeline with a fluid width since its an iframe and you're supposed to set up the with in px in your twitter account ?
Thanks :)
This seems to work for me:
#twitter-widget-0 {
width:100%;
}
where #twitter-widget-0 is the iframe it generates, placed in an appropriately-styled container.
It's not perfect: the widget generates its contents a bit differently depending on width, and margins, etc. won't be exactly the same after resizing; but this seems minor.
I'm curious as to why simple CSS didn't work for you - sorry if I'm missing something.
Thanks to all of you I found my way through:
It was almost as lack said, but we had to focus on the iframe instead:
.MyClassForTheDivThatContainTheiFrame iframe{
width:100%;
}
of course .MyClassForTheDivThatContainTheiFrame is also fluid with a % width
This logic will work to change at least the width and height:
#twitter-widget-0, #twitter-widget-1 {
float: none;
width: 100% !important;
height: 250px !important;
}
The only problem with shortening the height is that it hides the text box for people to send tweets but it does shorten the height. My guess is that if you want to add other CSS styling you can just put the !important clause. I also assume that if you have three widgets you would define #twitter-widget-2, etc.
Super hacky, but you can also do this :
<script type="text/javascript">
var checkTwitterResize = 0;
function resizeTwitterWidget() {
if ($('#twitter-widget-0').length > 0) {
checkTwitterResize++;
if ($('#twitter-widget-0').attr('width') != '100%') checkTwitterResize = 0;
$('#twitter-widget-0').attr('width', '100%');
// Ensures it's checked at least 10 times (script runs after initial resize)
if (checkTwitterResize < 10) setTimeout('resizeTwitterWidget()', 50);
} else setTimeout('resizeTwitterWidget()', 50);
}
resizeTwitterWidget();
</script>
This was a helpful thread, thanks. I'm working on a site that uses an older Twitter profile Widget, which I find easier to customise. So an alternative method, uses this to display the feed (customised to suit):
<script>
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 5,
interval: 6000,
width: 300,
height: 400,
theme: {
shell: {
background: 'transparent',
color: '#151515'
},
tweets: {
background: 'transparent',
color: '#151515',
links: '#007dba'
}
},
features: {
shell: false,
scrollbar: true,
loop: false,
live: true,
hashtags: true,
timestamp: true,
avatars: true,
behavior: 'all'
}
}).render().setUser('BlueLevel').start();
</script>
Then override the width by adding this to your stylesheet:
.twtr-doc {
width:100% !important;
}
You can see the various classes to modify by using IE9 in compatibility mode, then using F12 Developer Tools to see the html/css.
Hope that helps someone!
You can give your iframe a class, and try to apply CSS to it. At least to change the width to %.
This is not possible. You can set an exact width and height using the html width and height in the anchor tab. Other than that you are out of luck. No responsive or fluid capabilities.
It also has a min-width of 220px and a max-width of 520px.
<a class="twitter-timeline" width="520" height="700" data-dnt=true href="https://twitter.com/vertmob" data-widget-id="WIDGET_ID_HERE">Tweets by #vertmob</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
If you absolutely must do a fluid, you can code a javascript that changes that iframe's width after a resize event or using some javascript timers.
Can we see some code of yours to make some js code for this?
Attribute selector should work:
iframe[id*="twitter-widget"] {
width: 100%;
}
More here.

static pages that dont break?

Hi I want to do a fixed size page, but don't want the page to break or reflow at all if the user resizes the window. Is this a javascript function?
sample: http://www.neimanmarcus.com/
Most people put all the content of there page inside a div with an id, such as 'doc', then they would apply the following rule:
<body><div id="doc">
YOUR PAGE HERE
</div></body>
body {
test-align: center;
}
#doc {
margin: 0 auto;
text-align: left;
width: 940px
}
The "text-align" fixes an IE 6 issue, really you just need to assign a margin to your wrapping document div.
it doesn't need java script function .
but remember : don't use % for declaring width or height for elements in css.(for having a static element that resizing window doesn't effect that).
for example : "width:90%;" ==> replace this with "width:100px;"

Resources