percentage

CSS width in Percent related to the grand parent

混江龙づ霸主 提交于 2019-12-04 20:43:10
How to relate width in percent to the grand parent? You could simply relate width of li s to the parent ul which in turn it relates to the grand parent div : div{ overflow: hidden; width: 100%; } ul{ width: 1000%; } li{ width: 3%; } Use javascript: var g = document.getElementById('grandparent'); var w = g.clientWidth; if (w > 400) w *= .3; var c = document.getElementsByClassName('child'); for (var i=0; i < c.length; i++) { c[i].style.width = w+'px'; } I have a jsfiddle example . 来源: https://stackoverflow.com/questions/31317438/css-width-in-percent-related-to-the-grand-parent

Adding a percent column to MS Access Query

微笑、不失礼 提交于 2019-12-04 19:34:07
I'm trying to add a column which calculates percentages of different products in MS Access Query. Basically, this is the structure of the query that I'm trying to reach: Product | Total | Percentage Prod1 | 15 | 21.13% Prod2 | 23 | 32.39% Prod3 | 33 | 46.48% Product | 71 | 100% The formula for finding the percent I use is: ([Total Q of a Product]/[Totals of all Products])*100, but when I try to use the expression builder (since my SQL skills are basic) in MS Access to calculate it.. = [CountOfProcuts] / Sum([CountOfProducts]) ..I receive an error message "Cannot have aggregate function in

In R, how do I compute factors' percentage given on different variable? [duplicate]

≡放荡痞女 提交于 2019-12-04 14:34:42
问题 This question already has an answer here : percentage count by group using dplyr (1 answer) Closed 2 years ago . I am trying to compute percentage of factors in a variable, and want to make that percentage conditional on other variable. For example, I have data like this. State Ideology CO Liberal CO Liberal CO Liberal CO Conservative CO Conservative CO Independent DC Independent DC Conservative DC Liberal I am trying to find the percentage of each Liberal, Conservative, and Independent on

Keeping/scaling DIV Ratio with percentages

陌路散爱 提交于 2019-12-04 06:24:38
问题 At the moment I have a layout that pulls a number of thumbnails into a grid - each is defined by a style that keeps them a fixed ratio, (roughly 16:9) which is defined by pixel dimensions ( 389px x 230px ) but they are looking a bit small on high-res screens. The images are actually pulled into the DIV as a background that covers 100% width and height of the DIV and then the DIV's obviously control the aspect and size. What I am looking to do is have these DIV's dynamically resize based on

Applying a clearfix to nth-child without additional markup

时光怂恿深爱的人放手 提交于 2019-12-03 16:34:42
First up, for extreme clarity, here a JS fiddle demonstrating what I'm trying to achieve: http://jsfiddle.net/bb_matt/VsH7X/ Here's the explanation - my rationale: I'm creating a responsive site using the 1140 grid framework. It's a fairly complex layout. I've created a re-usable simple gallery class which can drop into any defined column size & using media queries, I apply relevant percentage widths to the li elements. Each of the li elements has a right margin of 5%. I'm using nth-child(xn+x) in the media queries to remove the right margin at the end of each row. Everything works well -

Percentage from Total SUM after GROUP BY SQL Server

早过忘川 提交于 2019-12-03 09:40:02
问题 I have these results: PersonID SUM(PA.Total) ------------------------- 1 75 2 75 3 15 4 15 5 60 6 60 With the table like: PersonID Total ------------------ 1 50 2 50 3 10 4 10 5 40 6 40 1 25 2 25 3 5 4 5 5 20 6 20 These are grouped by the person. Now I'm looking to add a column with the percentages for each person calculated from the total of all of their sums. For example: the total sum is 300, and hence I need a result like this: PersonID SUM(PA.Total) Percentage ---------------------------

In R, how do I compute factors' percentage given on different variable? [duplicate]

蓝咒 提交于 2019-12-03 08:34:40
This question already has an answer here : percentage count by group using dplyr (1 answer) I am trying to compute percentage of factors in a variable, and want to make that percentage conditional on other variable. For example, I have data like this. State Ideology CO Liberal CO Liberal CO Liberal CO Conservative CO Conservative CO Independent DC Independent DC Conservative DC Liberal I am trying to find the percentage of each Liberal, Conservative, and Independent on each state. I tried to use ddply like liberal_per<-ddply(data,.(State), summarize,total=table(Ideology)[1]/sum(Ideology)) But

CSS3 Box shadow size – percent units?

一个人想着一个人 提交于 2019-12-03 07:27:40
问题 I'm working on a project that needs to use CSS3 box-shadow property. That's fine, but I have found out that spread size of shadow can't be set to a percentage of parent object. I fully understand that box-shadow is not additive, thus it doesn't take the size of a parent as a reference. But given the fact that I need to have a fully responsive site with objects scaling fluidly (not only on breakpoints), but this also poses a problem – I can set shadow to spread property only in absolute units

jquery animate position in percentage

徘徊边缘 提交于 2019-12-03 07:08:27
how do I determine the positions in percentages? $(document).ready(function(){ $("#button").toggle(function(){ $("#slide").animate({top:-100%},1000); },function(){ $("#slide").animate({top:0%},1000); }); }); Please suggest. $(document).ready(function(){ $("#button").toggle(function(){ $("#slide").animate({top:'-100%'},1000); },function(){ $("#slide").animate({top:'0%'},1000); }); }); Add quotes. (I used single quotes, but js doesn't care if it is ' or ") 来源: https://stackoverflow.com/questions/11015399/jquery-animate-position-in-percentage

Percentage chance of saying something?

匆匆过客 提交于 2019-12-03 01:38:08
问题 How do I make it so .. 80% of the time it will say sendMessage("hi"); 5 % of the time it will say sendMessage("bye"); and 15% of the time it will say sendMessage("Test"); Does it have to do something with Math.random()? like if (Math.random() * 100 < 80) { sendMessage("hi"); } else if (Math.random() * 100 < 5) { sendMessage("bye"); } 回答1: Yes, Math.random() is an excellent way to accomplish this. What you want to do is compute a single random number, and then make decisions based on that: var