FAQ Database Discussion Community


How to make objects a percentage of the width of another

javascript,jquery,height,width
I'm trying to put 3 divs that fill the width of the window, and their width changes according to the dimensions of the window. However javascript seems to be giving a window width larger than it actually is causing the objects to flow out of the window causing scroll. You...

Can't get .getwidth() and .getheight() to work

java,android,height,width
I know there have been a lot of other questions on this topic, but I've looked through all of them, and still not gotten it to work. I've made this code for testing: public class MainActivity extends Activity { RelativeLayout layout; TextView widthtext; TextView heighttext; int width; int height; @Override...

setLineWidth works differently on different test machines

opengl-es,width,line,andengine,bezier-curve
I make a game in which I draw bezier curve like this: final VertexBufferObjectManager vbom = engine.getVertexBufferObjectManager(); final HighPerformanceMeshVertexBufferObject pMeshVBOM = new HighPerformanceMeshVertexBufferObject(vbom, pBufferData, pBufferData.length, DrawType.DYNAMIC, true, Mesh.VERTEXBUFFEROBJECTATTRIBUTES_DEFAULT); final HighPerformanceLineChainVertexBufferObject pLeftCurbLineChainVBOM = new HighPerformanceLineChainVertexBufferObject(vbom, triangleCount * 3, DrawType.DYNAMIC, true,...

Where does chrome developer tools show the real calculated width of an element

css,width,margin,padding
I've read somewhere on the internet on the box model and it says that the real width of a block element is not it's width as defined in the CSS but calculated according to the below formula: Real Width = margin-right + border-right + padding-right + width + padding-left +...

jQuery to position menu according to window width

jquery,menu,window,width
I'm trying to use a little bit of jQuery to move my menu depending on the width of the screen. The problem is that it's fine above a certain window width (1140px) but, part of the menu is obscured at other widths. I have a media query that displays the...

Elements disapear when height is relative

html,css,css3,height,width
I have 3 a with width:100%. I don't want to set a height so that the images keep their ratio. For some unknown reason the a elements desappear if height is not specified or set to auto. Any idea why this happens? HTML: <div class="cuerpo"> <div class="articulosysidebar"> <!--articulos--> <div class="articulos"></div>...

Javascript Image() object erroneously setting height and width to 0 sometimes

javascript,image,object,height,width
I'm working on an app that is dynamically generating images with Javascript's image() object. Code below, where object is the URL I am passing in - resizeImage: function(object) { var img = new Image(); img.src = object; console.log(img); console.log(img.width); console.log(img.height); var ratio; if(img.width > img.height) { ratio = 82/img.width; }...

JQuery Add/remove class dynamically based on scroll position AND window width

jquery,scroll,window,width
I want to add/remove a class based on scroll position AND window width. The class should be added when the user scrolls vertically past X AND the window width is larger than Y. If BOTH conditions are not met, the class should be removed. If the user scrolls back to...

Should VideoJS controls (CC, audio) appear below the video element when width gets narrow?

javascript,video,width,controls,video.js
When the width of the video is narrow, the VideoJS controls in the lower right (e.g., CC, audio, etc.) appear below the video element on the page. This can be demonstrated on the videojs.com home page by narrowing the browser window and hovering over the video to see the controls....

How to set width and height in jQuery

javascript,jquery,styles,height,width
I have a background image and I am trying to optimize the site by specifying height and width for all images. I cannot figure out how to set width to 450 and height to 350. <!-- BACKGROUND IMAGE --> <script src="js/supersized.3.2.1.min.js"></script> <script type="text/javascript"> jQuery(function($){ $.supersized({slides:[{image:"/images/heritage/background.jpg"}]});}); </script> ...

CSS: Make img fit completely in div

html,css,image,width
Working on a news site and once I get to mobile, I'd like it where the image fits inside the entire width of the div....whatever that might be. The images are originally 240px in width so we are talking about bumping them up. This is what I'm currently using: .thumb...

Control column widths in a ggplot2 graph with a series and inconsistent data

r,ggplot2,width,bar-chart,series
In the artificial data I have created for the MWE below I have tried to demonstrate the essence of a script I have created in R. As can be seen by the graph that gets produced from this code, on one of my conditions I don't have a "No" value...

How do I correctly create an offset between div's

html,css,css3,width,margin
At the moment I do this: .column-33 { width: 32%; float:left; } I want to have the width changed to 33.33% but my item is styled like this: .news-collection-item { margin: 0px 5px; } So what happens is there will only be 2 items in line when the width is...

How to get the correct Image height and width

c#,image,height,size,width
I am trying to calculate the size of a Rectangle using the Height and Width of an image in my project. The image (icon) is 20px W and 16px H. When I load it in from a ImageList and look at the image size, it shows that it is 16px...

Getting rid of extra width?

html,css,width
As shown in this picture, I am getting a lot of extra width that expands all the way to the right. I want only the words to be surrounded by that blue background color. Any help would be very much appreciated! My code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"...

Bootstrap button width is wider than normal

twitter-bootstrap,button,width
I have problem with bootstrap. At first there is problem with showing the first <section>, sometimes you must resize window and than first <section> appear. The second problem is with buttons in first <section>, look at search button please, why is it wider than normal? Here is my page: http://www.nibaru.com/core/mainpage.html...

jQuery - remove div by class when the screen is smaller than 1350px

jquery,html,width
I am working on a site with parallax scrolling that consists of 4 'pages' on which you can scroll trough by pressing an up or down button. The first 'page' contains a video background. There is no need for this 'page' to be visible on tablet and mobile. I can...

How I set the width of RelativeLayout to screen width?

android,width,screen,relativelayout,resolution
I have this RelativeLayout component and I want to set it to the entire screen width. How can I do that? atendente.xml <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <RelativeLayout style="@style/layoutAtendenteBalao" android:id="@+atendente/rltAtendenteBalao"> styles.xml <style name="layoutAtendenteBalao"> <item name="android:layout_width">fill_parent</item>...

Resize ALL images in WebView with Text Autosizing

image,webview,resize,width
I have a webview set up as: WebView wv = (WebView) findViewById(R.id.display_post_activity_content); wv.getSettings().setLoadWithOverviewMode(true); wv.getSettings().setUseWideViewPort(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { wv.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING); } else { wv.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); } wv.loadDataWithBaseURL("", content, "text/html", "UTF-8", ""); content is static HTML, with some inline CSS. No...

Auto width for nav li tags

html,css,size,width,nav
I am trying to make my nav menu li items width to auto size with the page. This means, if there a 4 li tags, the 4 tags should divide themselves to the screen width, and be equal. I tried using auto and 100% but nothing was working :( <div...

Shrink parent div to unknown number of floating children (css or js)

jquery,css,width,parent
I have a parent div (display:table) that wraps an unknown number of floating children. I now want it to always have the width of the children's rows. In other words: If the parent div is wider or narrower than a multiple of it's children, unused space remains within the parent...

How to get column width of a Win32 listbox?

winapi,listbox,width,multicolumn
I have a Win32 multicolumn listbox: HWND hListBox = CreateWindowEx(NULL, TEXT("LISTBOX"), NULL, LBS_MULTICOLUMN | WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY, 0, 25, 600, 450, hWnd, NULL, NULL, NULL); I add items like this: SendMessage(hListBox, LB_ADDSTRING, NULL, (LPARAM)("New items")); After I add some items into hListBox, columns width...

Javascript event change style with sass mixin

javascript,jquery,events,sass,width
I am working on a site with a sidebar. When you press the button the sidebar comes in from the left and pushes the main body away. The sidebar has a width of 280px and a max width of 80% (for mobile devices). At the moment my javascript looks like...

max-width for cell in wide table

html,css,width,max,html-table
I have a table which is very wide. Much wider than the width of the screen due to most of the columns having white-space: nowrap. I have a few "wrapping" columns with white-space: normal. These columns are squished extremely narrow. Setting width: 500px has no effect. Setting min-width: 500px forces...

CSS percentage width not working

html,css,navigation,width,percentage
I've been trying to edit the CSS for my website's navbar in order to transform it from having fixed width and height values into percentage values (in order for it to become responsive and work better with different screen sizes). However, when I converted the values, the individual divs didn't...

Jssor slider variable width based on window width

css,slider,styles,width,jssor
It is possible to change slides to fixed width based on window size (media queries)? I don't want it to scale or be in percetange, just fixed width depending on window size. For example something like this @media screen and (min-width: 320px) { .slides { width: 200px; } } @media...

CSS: How to make custom file upload button take full width (button works)

html,css,width,block,fixed-width
I am new to CSS and hope someone here can help me with this. I am trying to apply a simple custom style to a file upload button (as part of an HTML form) to make it look similar to other buttons on my page and to get a similar...

Can we change width of container in css using Bootstrap3

twitter-bootstrap-3,width,containers
how can i change width of container in bootstrap3. I want content in center of browser (70% of browser's width). <p> Use Bootply to design, prototype, or test the Bootstrap framework. Find examples, share code and rapidly build interfaces for Bootstrap. Use Bootply to design, prototype, or test the Bootstrap...

Nested CSS Tables - Nested table width is width of the first column

html,css,table,nested,width
I'm attempting to have some information for an element in columns (one, two, three, four - in the example). That element has child elements (five, six, seven, eight - in the example). I'm attempting to have the child element be 95% width of the parent table_div, however, it is 95%...

How to make a button responsive and centered?

css,width,block
I want to make a button centered and responsive. But I can't give it a width otherwise the background color goes with it. any solutions? Code: background-color: #03326c; font-size: 25px; height: 35px; margin-left: 530px; margin-top: -70px; position: relative; text-align: center; width: 180px; z-index: 100000; } <div class="product-button1"><a href="http://blabla.com/blabla.html" title="reserveren"><span class="reserverenButton1">Reserveer...

Remove width attribute from css class

javascript,jquery,html,css,width
Is there any way to remove width attribute present in css class using jquery or javascript. table.searchlistTable { border-collapse: collapse; margin: 0; padding: 0; width: 100%; } Note: Is there any other solution instead of below. $("table.searchlistTable").removeClass("searchlistTable"); $("table.searchlistTable").addClass("xyz"); Thank you....

Shinydashboard dashboardSidebar Width Setting

css,r,width,shiny
I'm using shiny (0.12.0) with shinydashboard (0.4.0) in R (RRO 8.0.3 CRAN-R 3.1.3) to create a UI, and I'm liking what I'm seeing. However, I would like to be able to control the width of the dashboardSidebar item, since I need to put some wide selector boxes in there. ui...

Using jquery to determine screen width

javascript,jquery,mobile,width
Having trouble getting this script to run properly on an iphone 6. Keeps coming up as "not mobile". What am I missing? $(document).ready(function(){ if ($(window).width < 700){ alert("mobile"); } else { alert("not mobile"); } }); EDIT: apologies, the code I typed here had a typo, but was not the cause...

Android WebView density issue

android,twitter-bootstrap,width,android-webview,pixel
Got some problems with the WebView class. I've got a WebView inside a RelativeLayout. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webViewFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFF00" android:orientation="vertical" > <WebView android:id="@+id/mWebView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"...

Hot to set weight for width and height?

android,view,height,width,android-layout-weight
I need to create view dynamical with width and height which are the percent of parent size.So I need to add weight for width and height for one view. Is it possible?

How can I make two iframes fit the width of the page?

html,css,iframe,width
My issue is that I have two iframes on the page, one for a persistent side menu and one for main body content. I want the side menu to take up roughly 12% of the screen (just personal choice) and then the content to fit the rest of the page...

Link the width of a div to a var

javascript,jquery,if-statement,width
I was trying to use this code: $("#a").click(function(event) { var n = $("#uno").innerWidth(); var a = $("#due").innerWidth(); if (n = a) { $("#uno").css('width', '1000px'); } else { $("#uno").css('width', '400px') } event.preventDefault(); }); So that when i click on that link, if the width of the div #uno matches the width...

Width 100% with white borders around it. WHy?

html,css,image,width
Ok, I'm trying to design a website that has an image at the top that spans the full width of the browser. And below that I want to put different colored div containers that also span the full width. kinda like this: http://hayden-demo.squarespace.com/ I've tried background-size:cover but I want different...

How do I make the dropdown menu width the same as the tab size?

css,drop-down-menu,menu,navigation,width
I'm new to this - sorry if this is a silly problem. When I hover over the dropdown menu options, the submenu appears, but the background of the submenu has a width of 100%, like the main menu. How can I alter it so that the submenu has a width...

percentage width in css not working

html,css,width,viewport,percentage
I was using a way to define my width property in css with the viewport measurement, css code: #content { position: absolute; background-color: white; width: 100vw; top: 115px; bottom: 30px; display: table; z-index: 0; } When I changed the width from width: 100vw; to width: 100%; my code ain't working...

Make QMenu have equal to parent (QPushButton)

c++,qt,widget,size,width
I have a QMenu which is assigned to a QPushButton and pops up when the button is pressed. It looks like this: However, I'd like to have the width of the menu to be equal the width of the button because as it is now it looks ugly and it's...

CSS: width behavior change when including bootstrap

css,twitter-bootstrap,width
I recently noticed that CSS property width does not have the same effect when using bootstrap. Could someone know why? I use firefox developer console to inspect box model and see actual dimensions. Simple html code: <div style="width=400px;height=30px;background-color:red;"></div> Here is a fiddle with a simple div with a fixed width/height....

Why doesn't the width (or max-width) property apply to my divs?

html,css,css3,width
JSFiddle here. I want the explicit width of 240px for my .left and .right divs. I tried this with width and max-width, as well as using spans instead of divs, didn't work. I am at a loss to understand why doesn't it apply at all, while a fixed width of...

div width auto adjust fill container

html,css,css3,responsive-design,width
Demo Fiddle : http://jsfiddle.net/UI_Designer/2gqy9s9k/1/ container have 4 blocks..Each div contain width:25%.. so fulfill the container... If i remove any one div container have empty space.. but I want to again fulfill the container.. Its is possible? .container{ width:100%; border:1px solid #333 } .badge-block{ float:left; width: 25%; } .badge-block img{ width:80%;...

Resize jQuery to auto script works … on all links

jquery,css,jquery-animate,width
I am trying to get a rollover script to resize my social network links from a 32px square icon to the same icon, plus the trailing address. So if I hovered over my Facebook link, the link would go from [f] [t] [g] to [f /facebookpage] [t] [g] and Twitter...

.height() returns height in percent, how to get it in pixels

javascript,jquery,height,width
I've got an element that I want to determine its height and width so I can fill it properly, but when I use $('#element').height(); $('#element').width(); it returns the values in percentages. I've been looking for a solution, but all the questions that come up in my searches imply that jQuery...

Width on :first-line?

css,css3,width,pseudo-element,heading
I would like to have a heading with the first line shorter than the rest of it. HTML Here is some code: <div> <h3>Lorem ipsum dolor sit amet who made up this fake Latin text</h3> </div> CSS div { width: 20em; border: 1px solid #000; } h3:first-line { background-color: yellow;...

How can I set element for entire width of the page? (Android)

android,width,screen,relativelayout,resolution
I want to set the "layoutAtendenteBalao" element for the entire width of the page. I tried to set it to <item name="android:layout_width">match_parent</item>, but it did not work. styles.xml <!--<style name="layoutAtendente"> <item name="android:layout_width">560px</item> <item name="android:layout_height">400px</item> <item name="android:layout_alignParentRight">true</item> <item name="android:layout_alignParentBottom">true</item> </style>--> <style...

Input does not respect max-width

html,css,table,input,width
I know my question is related to this one, but my situation is slightly different and also there is no solution in the other question. So, I have the following markup: <table> <tr> <td> <div>I respect max-width</div> </td> <td> <input value="I do not" /> </td> </tr> </table> With the following...

Make element fill rest of div without resizing Image

html,css,image,width
I want the Logo Image in this nav-bar to fill its height while still retaining its aspect ratio. The remaining width should be filled by the ul element. As long as the ul elements width is not 100% the image is displayed correctly. http://jsfiddle.net/5o0b4xLd/ How can I do that? The...

Why is my upper table not obeying the css width rule?

html,css,width
I have a simple set of two tables I am wanting to line up, but for some reason the upper one, while having the same rules as the second one doesn't want to obey the width rule. Here is the HTML: <body> <div> <div class="clientSearchWrapper"> <table class="clientSearchTableHeader"> <tr> <td colspan="6">Client...

I'm trying to move the links in navigation bar to right by 160px but i can't do that

html,css,width,navigationbar
Here is the css is using @import url(http://fonts.googleapis.com/css?family=Open+Sans:700); #cssmenu { background: #f96e5b; width: auto; } #cssmenu > ul { display:inline-block; margin: 0 auto; padding: 0; line-height: 1; text-align: 160px; zoom: 1; } #cssmenu ul:after { content: " "; display: block; font-size: 0; height: 0; clear: both; visibility: hidden; } #cssmenu...

“width: calc(100% / 3);” not working properly in any IE

css,internet-explorer,width,rounding,calc
I have a 3 column layout that should fill the whole screen so on my columns I am using: width: calc(100% / 3); So lets say for example my screen is 782px wide: 782 / 3 = 260.66̅ However the problem I have is in Internet Explorer, where it rounds...

CSS - Setting the width of a span in % with respect to its maximum width

html,css,width
I have two divs containing text stacked over eachother. The bottom text is in grey and the top one in red. I'd like to be able to specify the % of the portion of my top red div that I want to display with CSS. When using width: x%, the...

Nav bar does not take up full width of page when zoomed in

css,google-chrome,navigation,width,zoom
My problem can be seen here if you zoom into 110% or more on your browser. (It happens with Chrome, I'm not sure about other browsers). Basically, on the right side you can see a grey sliver of a few pixels after the 'contact' button when you zoom in. I'm...

Simplified: White space on mobile when defining div min-width

html,css,mobile,width,removing-whitespace
Problem: White space appears at bottom of page on mobile Chrome. I gutted everything to isolate the problem. There's now a single div. Page takes up full viewport just fine, until I define a min-width for the div. I tried a css reset. Did not solve problem. Am I just...

ios/xcode: Set visible width of button

ios,xcode,width
this should be simple but I am having trouble setting the width of textfields and/or buttons with placeholders in storyboard so that it looks right in the simulator.. I have set the width to 200. It looks find in storyboard, however, the textfield shrinks to the size of the placeholder...

How to fix DIV height when resizing width? Mobile/Table/PC browser compatible

css,resize,height,width,percentage
I have a trouble about % width and height: I would like to give every sizes in percentages (mobile, tablet, pc browser, etc. compatibility) but when I resize the browser WIDTH that causes the HEIGHT to be resized too FOR ALL ELEMENTS. How to stop height modifying when height isn't...

hide element based on width

jquery,resize,width,hide
I would like to hide element with class="wp-caption-text" if image size is <= 300 <div id="attachment_65209" style="width: 230px"> <a href="#" rel="lightbox[70848]"> <img src="/LCP-2015-05-31-s1.jpg" width="220" height="269"> </a> <p class="wp-caption-text">Sen. Charles Schwertner • District 5</p> </div> So far i tried using the following but no luck: <script> jQuery(window).on('resize load', function () {...

Set width of jQuery Tipsy bubble

jquery,width,tipsy
I'm using this plugin: http://onehackoranother.com/projects/jquery/tipsy/#options Is there a way (preferably via CSS or else via jQuery) to set the width of the the popup bubble? I'm applying tipsy on a link like so: $('#linktip').tipsy({ html: true, opacity: 1.0 }); <a href="" id="linktip" class="help" original-title='<asp:Literal ID="Literalfd19" Text="<%$Resources:pastelink %>" runat="server"/>'><i class="fa fa-info-circle...

CSS right sidebar fixed width and left contant fluid

html,css,width,fixed,fluid
I'm trying to add a sidebar which have a fixed width. But the content div should be fluid. Here is my code: .page-main{ padding: 10px; height: auto; overflow: hidden; } .page-content{ background-color: red; width: auto; overflow: hidden; } .page-side { float: right; width: 200px; background-color: green; } <div class="page-main"> <div...

Execute addClass if element width equals .. pixels

jquery,css,width,addclass
So I have this search box which shows and hides by changing its width now I want to add a class to the search icon if its width is larger than zero $("#search input").animate({width: "0px"}, 0); var searchWidth = $('#search input').width(); $('#search i').click( function() { //Change the width (show it)...

Why does percentage width work even if no explicit width value given for containing block?

html,css,css3,width
According to specifications for height the element's containing box needs to have an explicit height in order for percentage height to work on the element (i.e. a numerical value of 100% height used on all parent containing boxes). However why do the same rules not seem to apply for percentage...

How do I set max-width for a table cell?

html,css,width,max
Look at this code: #test { width: 20%; word-break: break-all; } <table> <tr> <td id="test"> <ul> <li>HiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiByeHiBye</li> </ul> </td> <td> Box 2: Where is its 80% width? </td> </tr> </table> How do I set max width 20% for #test with a super-long string non-broken in it? If I set width...

CSS:Confuse about element's width in percentage

css,width
Suppose I have an parent element without specific width, it has four children elements: <div> <a href>A</a> <a href>B</a> <a href>C</a> <a href>D</a> </div> each the child have a width set to width:25%; div { margin:0 auto; max-width: 880px; } a { display:inline-block; width: 25%; } However, the last element...

What usually happens when you don't define a div width?

html,css,width
The Context Usually, when I want a div to fill up the horizontal space, I would use width:100% However, on one of my pages, the width:100% tag would expand the page horizontally, resulting in a column of blank space to the right, and a scrollbar would appear on the x-axis....

getWidth() function in bitmap library of android doesn't return true image height

android,width,renderscript,android-bitmap
I wanted to load an .PNG image through my android application by using android.graphics.Bitmap library. I have succeeded to load it but there is some problem i can't figure out. My image pixel count is 144*144 but when i try to get the width of my loaded image by using...

Increasing max-width css for full calendar ignores scrollTime

jquery,css,width,fullcalendar
I am using the amazing fullcalendar and have it all set up. i have the start time shown set to 7 am as opposed to the default 6 am. { firstDay : 1 , //Monday scrollTime : "07:00:00" } this works fine with the standard max-width set by the example...

Android: How do I set column width for unequal quantities of buttons?

android,width,tablelayout
I have 3 columns of buttons, but the columns don't all contain the same quantity of buttons. What is the best practice for making all of the buttons appear the same size? I don't want to explicitly specify the button widths and I doubt that adding "dummy" buttons is best...