qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
Try this, and hopefully it will help: ``` #game { -webkit-backface-visibility: hidden; } ```
I had spent a lot of time trying to figure out this issue for **Ember Animated Outlets, Phonegap, and iOS** setup. Though simple, I had to add a background to each top-level parent element that was included in the css animations. In other words, make sure that at no point in your views there is an element that doesn't have a background. My setup was this for each template and all three elements had a background color assigned to them: `<header></header> <body class="content"></body> <footer></footer>`
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
The actual answer for my case is here. Someone was close with: -webkit-backface-visibility: hidden; But the real answer is -webkit-backface-visibility: hidden; needs to be added to the **parent** div.
I tried all the above and still had major flickering problems on Firefox and Chrome. I fixed it, or at least greatly reduced it to an acceptable issue by removing the box-shadow transform that was causing many repaints during the animation. I followed this and modified for my needs: <http://tobiasahlin.com/blog/how-to-animate-box-shadow/>
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
[Michael's answer](https://stackoverflow.com/questions/2946748/iphone-webkit-css-animations-cause-flicker/3349301#3349301) `-webkit-backface-visibility: hidden;` worked when we hit this problem. We had `translateZ(0px)` on our `<body>` tag to prevent an iOS 3.1.3 and earlier `IFRAME` boundary bug and it caused anims to flicker. Adding `-webkit-backface-visibility: hidden;` to each element we animated fixed the flicker! Life saver.
I tried all the above and still had major flickering problems on Firefox and Chrome. I fixed it, or at least greatly reduced it to an acceptable issue by removing the box-shadow transform that was causing many repaints during the animation. I followed this and modified for my needs: <http://tobiasahlin.com/blog/how-to-animate-box-shadow/>
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
Even though I had `-webkit-transform-style: preserve-3d;` and `-webkit-backface-visibility: hidden` the flicker was still happening. In my case the cause was the `z-index`. Increasing it on active element did help.
for me, flickering issue on safari solved by removing `will-change: transform;` to the animated element. also I could solve this issue by adding `overflow: hidden;` to the parent, but with this, all elements with `transform: translateZ()` got ineffective
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
[Michael's answer](https://stackoverflow.com/questions/2946748/iphone-webkit-css-animations-cause-flicker/3349301#3349301) `-webkit-backface-visibility: hidden;` worked when we hit this problem. We had `translateZ(0px)` on our `<body>` tag to prevent an iOS 3.1.3 and earlier `IFRAME` boundary bug and it caused anims to flicker. Adding `-webkit-backface-visibility: hidden;` to each element we animated fixed the flicker! Life saver.
Here's a new solution. I was setting the background-image with jQuery, and none of the 3d-rendering tricks worked. So I tried using classes to define the properties instead. Voilà! Smooth as butter. This causes flicker: ``` $('#banner').css('backgroundImage', 'url("slide_1.jpg")'; ``` Instead do: ``` $('#banner').attr('class', '.slide-1'); ``` with classes defined: ``` #banner { -webkit-transition: background-image .25s; } .slide-1 { background-image: url("slide_1.jpg"); } .slide-2 { background-image: url("slide_2.jpg"); } ```
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
``` div { -webkit-tap-highlight-color: rgba(255, 255, 255, 0); } ``` i noticed when i had a hover state on a div the page would flicker, even if i did not have any css or js attached to it. maybe this helps someone else.
I had spent a lot of time trying to figure out this issue for **Ember Animated Outlets, Phonegap, and iOS** setup. Though simple, I had to add a background to each top-level parent element that was included in the css animations. In other words, make sure that at no point in your views there is an element that doesn't have a background. My setup was this for each template and all three elements had a background color assigned to them: `<header></header> <body class="content"></body> <footer></footer>`
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
I had a problem with a "flickering" CSS transition as well. The animation in question was a menu sliding in from off screen, and just when the animation finished, the entire menu flashed/flickered. As it turned out, this was caused by an actual iOS feature, the ["tap highlight"](https://developer.apple.com/library/safari/#documentation/appleapplications/reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/css/property/-webkit-tap-highlight-color), which for some reason kicked in after the CSS animation finished (i.e. way after the actual tap), and highlighted the entire menu instead of only the element that was tapped. I "fixed" the issue by entirely disabling tap-highlight, as described [here](https://stackoverflow.com/questions/3516173/ipad-safari-how-to-disable-the-quick-blinking-effect-when-a-link-has-been-hit): ``` -webkit-tap-highlight-color: rgba(0,0,0,0); ```
I had to use an actual value (rather than 0): ``` .no-flick{ -webkit-backface-visibility: hidden; backface-visibility: hidden; -webkit-transform:translateZ(0.1px); transform: translateZ(0.1px); /* needs an actual value */ } ``` Example: ``` <div class="foo no-flick"></div> ``` [From what I've read](https://www.viget.com/articles/webkit-transform-kill-the-flash), the flicker is caused by the browser switching between hardware and software rendering. And I think browser manufacturers are aware of yea olde "translate3d(0,0,0)" to force hardware rendering -- so they may now be ignoring these fake values. => Using an actual value may cause things to "stick". Anyway, worked for me.
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
``` body {-webkit-transform:translate3d(0,0,0);} ```
for me, flickering issue on safari solved by removing `will-change: transform;` to the animated element. also I could solve this issue by adding `overflow: hidden;` to the parent, but with this, all elements with `transform: translateZ()` got ineffective
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
Try this, and hopefully it will help: ``` #game { -webkit-backface-visibility: hidden; } ```
I've experienced flickering when performing a slide transition when using a default Android web browser. I've used the following transition css: ``` -webkit-transition: all 2s; -webkit-transform: translate(100%,0); ``` None of the workarounds mentioned in this thread have helped to solve the issue. Finally I've found the solution. The source of flickering is the **all** keyword which means to perform all possible transitions. I've changed it to perform only transformation and the issue has been solved: ``` -webkit-transition: -webkit-transform 2s; -webkit-transform: translate(100%,0); ```
2,946,748
This is the iphone site: <http://www.thevisionairegroup.com/projects/accessorizer/site/> After you click "play now" you'll get to a game. The guns will scroll in. You can scroll the purse and accessories up and down. You can see that when you let go they snap into place. Just as that snap happens, there's a flicker that occurs. The only webkit animations I'm using are: ``` '-webkit-transition': 'none' '-webkit-transition': 'all 0.2s ease-out' '-webkit-transform': 'translate(XXpx, XXpx)' ``` I choose either the first or second transition based on whether or not I want it to animate, and the transform is the only way I move things around. The biggest issue though is when you click "Match items", then click "Play again". You'll see as the guns animate in, the entire background of the accessories/purses goes white. Can someone please radiate me with some insight asto why this is happening??
2010/06/01
[ "https://Stackoverflow.com/questions/2946748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/354990/" ]
Try this, and hopefully it will help: ``` #game { -webkit-backface-visibility: hidden; } ```
Try this **solution**. It works for me in **Phonegap + jQM 1.4.0**: Change this `<meta name="viewport" content="width=device-width, initial-scale=1">` To this instead: `<meta name="viewport" content="width=device-width, user-scalable=no" />` Read more here: <http://www.fishycode.com/post/40863390300/fixing-jquery-mobiles-none-transition-flicker-in>
11,211,640
I've a console application that uses MEF. It works fine locally and when deployed to a development machine. When deployed to the release machine it throws composition errors. The development and release machine are both virtual sql server 2008 r2 machines, with the same spec and mostly the same software and components installed. There is a build and deployment process, but even copying the files from dev to release and running them results in the same error. Are there any prerequisites I need for MEF that might be missing on the release machine, or permissions? ``` The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Resulting in: An exception occurred while trying to create an instance of type 'XXX.XXX.Dispatch.EmailDispatcher'. Resulting in: Cannot activate part 'XXX.XXX.Dispatch.EmailDispatcher'. Element: Lifetime.CrmBroker.Dispatch.EmailDispatcher --> XXX.XXX.Dispatch.EmailDispatcher --> AssemblyCatalog (Assembly="XXX.XXX, Version=1.1.2264.871, Culture=neutral, PublicKeyToken=null") Resulting in: Cannot get export 'XXX.XXX.Dispatch.EmailDispatcher (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher")' from part 'XXX.XXX.Dispatch.EmailDispatcher'. Element: XXXX.XXX.Dispatch.EmailDispatcher (ContractName="XXXX.XXX.Dispatch.IEntityTypeDispatcher") --> XXX.XXX.Dispatch.EmailDispatcher --> AssemblyCatalog (Assembly="XXX.XXX, Version=1.1.2264.871, Culture=neutral, PublicKeyToken=null") Resulting in: Cannot set import 'XXX.XXXX.Dispatch.DispatcherRepository.Dispatchers (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher")' on part 'XXX.XXX.Dispatch.DispatcherRepository'. Element: XXX.XXX.Dispatch.DispatcherRepository.Dispatchers (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher") --> XXX.XXX.Dispatch.DispatcherRepository (System.ComponentModel.Composition.CompositionException) ```
2012/06/26
[ "https://Stackoverflow.com/questions/11211640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/286231/" ]
Add some code to catch the `CompositionException` and get information about the root cause like this: ``` catch (CompositionException e) { // "unable to load one or more of the requested types" hints at a // ReflectionTypeLoadException, so cast to that var loadException = (ReflectionTypeLoadException)e.Errors.First(); // as the error said, // "Retrieve the LoaderExceptions property for more information" var cause = loadException.LoaderExceptions.First(); // print, log or extract the information in some other way Debug.Print(cause.Message); } ``` It seems likely that it is just a missing dependency though.
Check your dynamically loaded type's constructor. MEF hides problems in your constructors behind MEF errors that don't help. Make sure you have error handling in the constructor, and then add some logging to catch the "real" exception.
11,211,640
I've a console application that uses MEF. It works fine locally and when deployed to a development machine. When deployed to the release machine it throws composition errors. The development and release machine are both virtual sql server 2008 r2 machines, with the same spec and mostly the same software and components installed. There is a build and deployment process, but even copying the files from dev to release and running them results in the same error. Are there any prerequisites I need for MEF that might be missing on the release machine, or permissions? ``` The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information. 1) Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Resulting in: An exception occurred while trying to create an instance of type 'XXX.XXX.Dispatch.EmailDispatcher'. Resulting in: Cannot activate part 'XXX.XXX.Dispatch.EmailDispatcher'. Element: Lifetime.CrmBroker.Dispatch.EmailDispatcher --> XXX.XXX.Dispatch.EmailDispatcher --> AssemblyCatalog (Assembly="XXX.XXX, Version=1.1.2264.871, Culture=neutral, PublicKeyToken=null") Resulting in: Cannot get export 'XXX.XXX.Dispatch.EmailDispatcher (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher")' from part 'XXX.XXX.Dispatch.EmailDispatcher'. Element: XXXX.XXX.Dispatch.EmailDispatcher (ContractName="XXXX.XXX.Dispatch.IEntityTypeDispatcher") --> XXX.XXX.Dispatch.EmailDispatcher --> AssemblyCatalog (Assembly="XXX.XXX, Version=1.1.2264.871, Culture=neutral, PublicKeyToken=null") Resulting in: Cannot set import 'XXX.XXXX.Dispatch.DispatcherRepository.Dispatchers (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher")' on part 'XXX.XXX.Dispatch.DispatcherRepository'. Element: XXX.XXX.Dispatch.DispatcherRepository.Dispatchers (ContractName="XXX.XXX.Dispatch.IEntityTypeDispatcher") --> XXX.XXX.Dispatch.DispatcherRepository (System.ComponentModel.Composition.CompositionException) ```
2012/06/26
[ "https://Stackoverflow.com/questions/11211640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/286231/" ]
Thanks for the replies guys, handy tips on debugging MEF. It turns out that the problem was I didn't have Entity Framework 4.1 installed on the machine. MEF was swallowing up the exception that would have been thrown, I never found it, but I did a detailed comparison between the environments and just tried installing EF 4.1 to see if it worked.
Check your dynamically loaded type's constructor. MEF hides problems in your constructors behind MEF errors that don't help. Make sure you have error handling in the constructor, and then add some logging to catch the "real" exception.
17,138,785
As the title says, I am trying to center vertically a CSS triangle/arrow onto the right side of a div, and of course, I am looking to do this using a pure CSS solution. I would have included pictures, but because of my low-rep, I can't. Note: My current code isn't working properly and is not cross-browser compatible (i.e. Chrome puts the arrow on the top right~ but on Firefox, it gets squished down outside the bounds) **My code** *HTML*: ``` <div class="main-panel"> <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> <div class="right-panel"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque nisl vitae nulla dignissim, at rutrum nunc interdum. Mauris et facilisis orci. Phasellus ac libero id nisl malesuada ultricies. Aenean vitae cursus velit. Nulla sit amet leo eu enim scelerisque volutpat. Vivamus gravida felis et pulvinar mollis. Sed bibendum consectetur nisi, sit amet tincidunt enim interdum a. Duis sed gravida felis. Fusce mauris est, bibendum a neque et, fringilla placerat magna. Vestibulum pellentesque massa quis bibendum dapibus. Praesent pharetra ipsum id libero dapibus rutrum. Quisque accumsan dictum lacinia. Mauris ut mi nec orci accumsan consequat. Donec blandit augue eget nulla fermentum, quis porttitor lacus feugiat. Proin vehicula dolor id lorem egestas elementum. Nullam vitae rutrum tortor. Proin varius adipiscing nibh. Vivamus ultrices nibh nec varius bibendum. Integer quis nisi sed metus adipiscing sagittis. Curabitur congue, nisi nec pretium suscipit, mi leo posuere dui, pellentesque dapibus ligula urna a ligula. Quisque mauris nisl, interdum eu est in, elementum cursus arcu. Sed suscipit vel erat vitae viverra. Mauris neque ipsum, bibendum eget hendrerit ac, vulputate in eros. Ut tincidunt, urna ac auctor porttitor, mauris purus varius erat, ut pellentesque urna turpis non nibh. Aenean sed neque a velit tristique tristique. Praesent id cursus libero. Vestibulum pulvinar feugiat neque pretium suscipit. Nam vitae magna eget elit aliquam accumsan. Duis et eleifend enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec nunc est, commodo quis pretium vitae, lacinia ac lectus. Cras mi tellus, suscipit non leo eget, auctor feugiat mauris. Praesent vitae vehicula ipsum, nec ultrices arcu. Proin mollis leo sit amet erat scelerisque feugiat. Nullam eget varius ante. Praesent a laoreet libero. Suspendisse ut eros et odio rhoncus malesuada. Integer laoreet, leo at fringilla volutpat, augue lorem tincidunt augue, sit amet feugiat erat neque in est. Phasellus imperdiet, nisi vel faucibus auctor, sapien orci mollis est, tincidunt vehicula nisi nunc sit amet purus. Sed cursus ipsum nisi, id elementum leo feugiat in. Phasellus vitae arcu ac ligula pellentesque malesuada. Maecenas vulputate nunc et consequat pellentesque. Nulla semper quam a orci eleifend, vel gravida est euismod. Nam fermentum, nisi ullamcorper congue convallis, turpis purus lacinia ligula, ac posuere urna est non felis. Cras lobortis ligula neque, vel fermentum magna facilisis sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque a quam nec sem vestibulum dapibus quis non lacus. Integer eget ligula eu turpis pretium iaculis. Cras gravida ligula in mauris bibendum placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ac tristique risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque diam nisi, sodales vel nisi a, sollicitudin commodo ipsum. Fusce elementum nisi ac semper dignissim. Etiam nec felis dapibus lacus faucibus vehicula eget eu odio. Sed id risus tellus. Curabitur in luctus orci. </p> </div> </div> ``` *CSS*: ``` * { margin: 0; padding: 0; font-family: "Helvetica Neue",Helvetica,sans-serif; line-height: 20px; } .main-panel { min-width: 700px; width: 100%; min-height: 500px; max-height: 700px; display: -webkit-flex; display: flex; background: rgba(64, 64, 64, 0.4); } .left-panel { border-width: 2px 0 0 0 0; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* Standard syntax; must be last */ box-shadow: 0px 0px 7px white inset; -moz-box-shadow: 0px 0px 7px white inset; -webkit-box-shadow: 0px 0px 7px white inset; overflow: hidden; min-width: 180px; max-width: 280px; padding: 5px 0 5px 7px; } .right-panel { background-color: white; overflow: hidden; padding: 5px 5px 5px 5px; -webkit-flex: 1; flex: 1; flex-basis: auto; } .left-panel > .page-nav > .page-tab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: solid 1px rgba(245, 245, 245, 0.4); box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3) inset; border-top-width: 1px; border-right-width: 0; padding: 0 5px; margin-bottom: 0px; cursor: pointer; height: 25px; text-transform: uppercase; font-weight: bold; font-size: 11px; list-style: none; text-align: center; } .left-panel > .page-nav > .page-tab.active { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* Standard syntax; must be last */ } .left-panel > .page-nav > .page-tab.active:after { content: " "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; margin-right: -5px; display: inline-block; float: right; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } ``` JSFiddle link: <http://jsfiddle.net/LvG2C/>
2013/06/16
[ "https://Stackoverflow.com/questions/17138785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1581233/" ]
Try like this: ``` .left-panel > .page-nav > .page-tab { position: relative; } .left-panel > .page-nav > .page-tab.active:after { width: 0px; height: 0px; border-style: solid; border-width: 7px 7px 7px 0; border-color: transparent #ffffff transparent transparent; position: absolute; top: 50%; right: 0; margin-top: -7px; content: ""; } ``` height triangle 14px, for vertical alignment to do it: 14/2 = 7, for this margin-top: -7px; [***Example***](http://jsfiddle.net/ShootingStar/VXUCJ/1/) By the way, the [***generator triangles***](http://apps.eky.hk/css-triangle-generator/)
*Alternative solution keeping float in the run* Using line-height value + font-size to set size of arrow and margin. <http://jsfiddle.net/LvG2C/3/> **edit:** what follows is **not compatible with text-ellipsis** if you turn **`<a>`** as one inline-block. you use float. it is not compatible with vertical-align. You can set as inline-box and the arrow too to vertical-align them mutually. give a width to a to push arrow all the way : <http://jsfiddle.net/LvG2C/1/> ``` .left-panel > .page-nav > .page-tab.active:after { content:" "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; vertical-align:middle; display: inline-block; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } a { display:inline-block; width:100%; vertical-align:middle; margin-right:-3px; } ```
17,138,785
As the title says, I am trying to center vertically a CSS triangle/arrow onto the right side of a div, and of course, I am looking to do this using a pure CSS solution. I would have included pictures, but because of my low-rep, I can't. Note: My current code isn't working properly and is not cross-browser compatible (i.e. Chrome puts the arrow on the top right~ but on Firefox, it gets squished down outside the bounds) **My code** *HTML*: ``` <div class="main-panel"> <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> <div class="right-panel"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque nisl vitae nulla dignissim, at rutrum nunc interdum. Mauris et facilisis orci. Phasellus ac libero id nisl malesuada ultricies. Aenean vitae cursus velit. Nulla sit amet leo eu enim scelerisque volutpat. Vivamus gravida felis et pulvinar mollis. Sed bibendum consectetur nisi, sit amet tincidunt enim interdum a. Duis sed gravida felis. Fusce mauris est, bibendum a neque et, fringilla placerat magna. Vestibulum pellentesque massa quis bibendum dapibus. Praesent pharetra ipsum id libero dapibus rutrum. Quisque accumsan dictum lacinia. Mauris ut mi nec orci accumsan consequat. Donec blandit augue eget nulla fermentum, quis porttitor lacus feugiat. Proin vehicula dolor id lorem egestas elementum. Nullam vitae rutrum tortor. Proin varius adipiscing nibh. Vivamus ultrices nibh nec varius bibendum. Integer quis nisi sed metus adipiscing sagittis. Curabitur congue, nisi nec pretium suscipit, mi leo posuere dui, pellentesque dapibus ligula urna a ligula. Quisque mauris nisl, interdum eu est in, elementum cursus arcu. Sed suscipit vel erat vitae viverra. Mauris neque ipsum, bibendum eget hendrerit ac, vulputate in eros. Ut tincidunt, urna ac auctor porttitor, mauris purus varius erat, ut pellentesque urna turpis non nibh. Aenean sed neque a velit tristique tristique. Praesent id cursus libero. Vestibulum pulvinar feugiat neque pretium suscipit. Nam vitae magna eget elit aliquam accumsan. Duis et eleifend enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec nunc est, commodo quis pretium vitae, lacinia ac lectus. Cras mi tellus, suscipit non leo eget, auctor feugiat mauris. Praesent vitae vehicula ipsum, nec ultrices arcu. Proin mollis leo sit amet erat scelerisque feugiat. Nullam eget varius ante. Praesent a laoreet libero. Suspendisse ut eros et odio rhoncus malesuada. Integer laoreet, leo at fringilla volutpat, augue lorem tincidunt augue, sit amet feugiat erat neque in est. Phasellus imperdiet, nisi vel faucibus auctor, sapien orci mollis est, tincidunt vehicula nisi nunc sit amet purus. Sed cursus ipsum nisi, id elementum leo feugiat in. Phasellus vitae arcu ac ligula pellentesque malesuada. Maecenas vulputate nunc et consequat pellentesque. Nulla semper quam a orci eleifend, vel gravida est euismod. Nam fermentum, nisi ullamcorper congue convallis, turpis purus lacinia ligula, ac posuere urna est non felis. Cras lobortis ligula neque, vel fermentum magna facilisis sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque a quam nec sem vestibulum dapibus quis non lacus. Integer eget ligula eu turpis pretium iaculis. Cras gravida ligula in mauris bibendum placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ac tristique risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque diam nisi, sodales vel nisi a, sollicitudin commodo ipsum. Fusce elementum nisi ac semper dignissim. Etiam nec felis dapibus lacus faucibus vehicula eget eu odio. Sed id risus tellus. Curabitur in luctus orci. </p> </div> </div> ``` *CSS*: ``` * { margin: 0; padding: 0; font-family: "Helvetica Neue",Helvetica,sans-serif; line-height: 20px; } .main-panel { min-width: 700px; width: 100%; min-height: 500px; max-height: 700px; display: -webkit-flex; display: flex; background: rgba(64, 64, 64, 0.4); } .left-panel { border-width: 2px 0 0 0 0; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* Standard syntax; must be last */ box-shadow: 0px 0px 7px white inset; -moz-box-shadow: 0px 0px 7px white inset; -webkit-box-shadow: 0px 0px 7px white inset; overflow: hidden; min-width: 180px; max-width: 280px; padding: 5px 0 5px 7px; } .right-panel { background-color: white; overflow: hidden; padding: 5px 5px 5px 5px; -webkit-flex: 1; flex: 1; flex-basis: auto; } .left-panel > .page-nav > .page-tab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: solid 1px rgba(245, 245, 245, 0.4); box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3) inset; border-top-width: 1px; border-right-width: 0; padding: 0 5px; margin-bottom: 0px; cursor: pointer; height: 25px; text-transform: uppercase; font-weight: bold; font-size: 11px; list-style: none; text-align: center; } .left-panel > .page-nav > .page-tab.active { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* Standard syntax; must be last */ } .left-panel > .page-nav > .page-tab.active:after { content: " "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; margin-right: -5px; display: inline-block; float: right; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } ``` JSFiddle link: <http://jsfiddle.net/LvG2C/>
2013/06/16
[ "https://Stackoverflow.com/questions/17138785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1581233/" ]
Try like this: ``` .left-panel > .page-nav > .page-tab { position: relative; } .left-panel > .page-nav > .page-tab.active:after { width: 0px; height: 0px; border-style: solid; border-width: 7px 7px 7px 0; border-color: transparent #ffffff transparent transparent; position: absolute; top: 50%; right: 0; margin-top: -7px; content: ""; } ``` height triangle 14px, for vertical alignment to do it: 14/2 = 7, for this margin-top: -7px; [***Example***](http://jsfiddle.net/ShootingStar/VXUCJ/1/) By the way, the [***generator triangles***](http://apps.eky.hk/css-triangle-generator/)
Nice use of CSS3 there. If your client is okay with you using cSS3 then your method suffices (if it isn't the best option out there). However, I work for clients that require the use of legacy browsers and as a matter of fact my work still actively uses IE7/8. This is the approach I would employ for a simple arrow styling solution. It is simple, robust, and compatible with IE5+. IN addition, this method will work beautifully on mobile devices and tablet browsers. (Know your customers/client needs and decide if you want to fall back on this method). 1. Create the arrow in photoshop and save it as a .png . The file should only be 50bytes or something ridiculously small. (5px X 10px). 2. Create the gradient in photoshop as well. It should be (1px wide) and the height should match be exactly two times that of an li element. Create a normal / hover state on the image. So the first y pixels should be normal gradient and the next y pixels should be hover over gradient. We will use css to change the positioning of the background. NO reason to create 2 gradient images. 3. Deploy CSS2. li { background: url(gradient.png) repeat-x; height: 30px; line-height: 30px; text-align: center; color: #000; font-size: 14px; } li:hover { background-position: 0 -30px; } li a { background: url(arrow.png) no-repeat 100% center; } This should get you started. And show you an alternative approach. ### SO is bugging out and can't get the code to code block to format
17,138,785
As the title says, I am trying to center vertically a CSS triangle/arrow onto the right side of a div, and of course, I am looking to do this using a pure CSS solution. I would have included pictures, but because of my low-rep, I can't. Note: My current code isn't working properly and is not cross-browser compatible (i.e. Chrome puts the arrow on the top right~ but on Firefox, it gets squished down outside the bounds) **My code** *HTML*: ``` <div class="main-panel"> <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> <div class="right-panel"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque nisl vitae nulla dignissim, at rutrum nunc interdum. Mauris et facilisis orci. Phasellus ac libero id nisl malesuada ultricies. Aenean vitae cursus velit. Nulla sit amet leo eu enim scelerisque volutpat. Vivamus gravida felis et pulvinar mollis. Sed bibendum consectetur nisi, sit amet tincidunt enim interdum a. Duis sed gravida felis. Fusce mauris est, bibendum a neque et, fringilla placerat magna. Vestibulum pellentesque massa quis bibendum dapibus. Praesent pharetra ipsum id libero dapibus rutrum. Quisque accumsan dictum lacinia. Mauris ut mi nec orci accumsan consequat. Donec blandit augue eget nulla fermentum, quis porttitor lacus feugiat. Proin vehicula dolor id lorem egestas elementum. Nullam vitae rutrum tortor. Proin varius adipiscing nibh. Vivamus ultrices nibh nec varius bibendum. Integer quis nisi sed metus adipiscing sagittis. Curabitur congue, nisi nec pretium suscipit, mi leo posuere dui, pellentesque dapibus ligula urna a ligula. Quisque mauris nisl, interdum eu est in, elementum cursus arcu. Sed suscipit vel erat vitae viverra. Mauris neque ipsum, bibendum eget hendrerit ac, vulputate in eros. Ut tincidunt, urna ac auctor porttitor, mauris purus varius erat, ut pellentesque urna turpis non nibh. Aenean sed neque a velit tristique tristique. Praesent id cursus libero. Vestibulum pulvinar feugiat neque pretium suscipit. Nam vitae magna eget elit aliquam accumsan. Duis et eleifend enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec nunc est, commodo quis pretium vitae, lacinia ac lectus. Cras mi tellus, suscipit non leo eget, auctor feugiat mauris. Praesent vitae vehicula ipsum, nec ultrices arcu. Proin mollis leo sit amet erat scelerisque feugiat. Nullam eget varius ante. Praesent a laoreet libero. Suspendisse ut eros et odio rhoncus malesuada. Integer laoreet, leo at fringilla volutpat, augue lorem tincidunt augue, sit amet feugiat erat neque in est. Phasellus imperdiet, nisi vel faucibus auctor, sapien orci mollis est, tincidunt vehicula nisi nunc sit amet purus. Sed cursus ipsum nisi, id elementum leo feugiat in. Phasellus vitae arcu ac ligula pellentesque malesuada. Maecenas vulputate nunc et consequat pellentesque. Nulla semper quam a orci eleifend, vel gravida est euismod. Nam fermentum, nisi ullamcorper congue convallis, turpis purus lacinia ligula, ac posuere urna est non felis. Cras lobortis ligula neque, vel fermentum magna facilisis sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque a quam nec sem vestibulum dapibus quis non lacus. Integer eget ligula eu turpis pretium iaculis. Cras gravida ligula in mauris bibendum placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ac tristique risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque diam nisi, sodales vel nisi a, sollicitudin commodo ipsum. Fusce elementum nisi ac semper dignissim. Etiam nec felis dapibus lacus faucibus vehicula eget eu odio. Sed id risus tellus. Curabitur in luctus orci. </p> </div> </div> ``` *CSS*: ``` * { margin: 0; padding: 0; font-family: "Helvetica Neue",Helvetica,sans-serif; line-height: 20px; } .main-panel { min-width: 700px; width: 100%; min-height: 500px; max-height: 700px; display: -webkit-flex; display: flex; background: rgba(64, 64, 64, 0.4); } .left-panel { border-width: 2px 0 0 0 0; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* Standard syntax; must be last */ box-shadow: 0px 0px 7px white inset; -moz-box-shadow: 0px 0px 7px white inset; -webkit-box-shadow: 0px 0px 7px white inset; overflow: hidden; min-width: 180px; max-width: 280px; padding: 5px 0 5px 7px; } .right-panel { background-color: white; overflow: hidden; padding: 5px 5px 5px 5px; -webkit-flex: 1; flex: 1; flex-basis: auto; } .left-panel > .page-nav > .page-tab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: solid 1px rgba(245, 245, 245, 0.4); box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3) inset; border-top-width: 1px; border-right-width: 0; padding: 0 5px; margin-bottom: 0px; cursor: pointer; height: 25px; text-transform: uppercase; font-weight: bold; font-size: 11px; list-style: none; text-align: center; } .left-panel > .page-nav > .page-tab.active { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* Standard syntax; must be last */ } .left-panel > .page-nav > .page-tab.active:after { content: " "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; margin-right: -5px; display: inline-block; float: right; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } ``` JSFiddle link: <http://jsfiddle.net/LvG2C/>
2013/06/16
[ "https://Stackoverflow.com/questions/17138785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1581233/" ]
Try like this: ``` .left-panel > .page-nav > .page-tab { position: relative; } .left-panel > .page-nav > .page-tab.active:after { width: 0px; height: 0px; border-style: solid; border-width: 7px 7px 7px 0; border-color: transparent #ffffff transparent transparent; position: absolute; top: 50%; right: 0; margin-top: -7px; content: ""; } ``` height triangle 14px, for vertical alignment to do it: 14/2 = 7, for this margin-top: -7px; [***Example***](http://jsfiddle.net/ShootingStar/VXUCJ/1/) By the way, the [***generator triangles***](http://apps.eky.hk/css-triangle-generator/)
An alternative would be to set a class on the elements that you wish to have an arrow on the left side centered vertically. In the class would look something like: ``` .left-arrow { background: url('/images/arrow.png') 0% 50% no-repeat; padding-left: 20px; // Number of pixels you need to offset the content to make the content come after the arrow the way you want it to. } ``` This would mean that any element with a class="left-arrow" attribute would have an arrow centered vertically on the left side. Then the nav code would look like: ``` <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link left-arrow">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> ```
17,138,785
As the title says, I am trying to center vertically a CSS triangle/arrow onto the right side of a div, and of course, I am looking to do this using a pure CSS solution. I would have included pictures, but because of my low-rep, I can't. Note: My current code isn't working properly and is not cross-browser compatible (i.e. Chrome puts the arrow on the top right~ but on Firefox, it gets squished down outside the bounds) **My code** *HTML*: ``` <div class="main-panel"> <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> <div class="right-panel"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque nisl vitae nulla dignissim, at rutrum nunc interdum. Mauris et facilisis orci. Phasellus ac libero id nisl malesuada ultricies. Aenean vitae cursus velit. Nulla sit amet leo eu enim scelerisque volutpat. Vivamus gravida felis et pulvinar mollis. Sed bibendum consectetur nisi, sit amet tincidunt enim interdum a. Duis sed gravida felis. Fusce mauris est, bibendum a neque et, fringilla placerat magna. Vestibulum pellentesque massa quis bibendum dapibus. Praesent pharetra ipsum id libero dapibus rutrum. Quisque accumsan dictum lacinia. Mauris ut mi nec orci accumsan consequat. Donec blandit augue eget nulla fermentum, quis porttitor lacus feugiat. Proin vehicula dolor id lorem egestas elementum. Nullam vitae rutrum tortor. Proin varius adipiscing nibh. Vivamus ultrices nibh nec varius bibendum. Integer quis nisi sed metus adipiscing sagittis. Curabitur congue, nisi nec pretium suscipit, mi leo posuere dui, pellentesque dapibus ligula urna a ligula. Quisque mauris nisl, interdum eu est in, elementum cursus arcu. Sed suscipit vel erat vitae viverra. Mauris neque ipsum, bibendum eget hendrerit ac, vulputate in eros. Ut tincidunt, urna ac auctor porttitor, mauris purus varius erat, ut pellentesque urna turpis non nibh. Aenean sed neque a velit tristique tristique. Praesent id cursus libero. Vestibulum pulvinar feugiat neque pretium suscipit. Nam vitae magna eget elit aliquam accumsan. Duis et eleifend enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec nunc est, commodo quis pretium vitae, lacinia ac lectus. Cras mi tellus, suscipit non leo eget, auctor feugiat mauris. Praesent vitae vehicula ipsum, nec ultrices arcu. Proin mollis leo sit amet erat scelerisque feugiat. Nullam eget varius ante. Praesent a laoreet libero. Suspendisse ut eros et odio rhoncus malesuada. Integer laoreet, leo at fringilla volutpat, augue lorem tincidunt augue, sit amet feugiat erat neque in est. Phasellus imperdiet, nisi vel faucibus auctor, sapien orci mollis est, tincidunt vehicula nisi nunc sit amet purus. Sed cursus ipsum nisi, id elementum leo feugiat in. Phasellus vitae arcu ac ligula pellentesque malesuada. Maecenas vulputate nunc et consequat pellentesque. Nulla semper quam a orci eleifend, vel gravida est euismod. Nam fermentum, nisi ullamcorper congue convallis, turpis purus lacinia ligula, ac posuere urna est non felis. Cras lobortis ligula neque, vel fermentum magna facilisis sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque a quam nec sem vestibulum dapibus quis non lacus. Integer eget ligula eu turpis pretium iaculis. Cras gravida ligula in mauris bibendum placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ac tristique risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque diam nisi, sodales vel nisi a, sollicitudin commodo ipsum. Fusce elementum nisi ac semper dignissim. Etiam nec felis dapibus lacus faucibus vehicula eget eu odio. Sed id risus tellus. Curabitur in luctus orci. </p> </div> </div> ``` *CSS*: ``` * { margin: 0; padding: 0; font-family: "Helvetica Neue",Helvetica,sans-serif; line-height: 20px; } .main-panel { min-width: 700px; width: 100%; min-height: 500px; max-height: 700px; display: -webkit-flex; display: flex; background: rgba(64, 64, 64, 0.4); } .left-panel { border-width: 2px 0 0 0 0; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* Standard syntax; must be last */ box-shadow: 0px 0px 7px white inset; -moz-box-shadow: 0px 0px 7px white inset; -webkit-box-shadow: 0px 0px 7px white inset; overflow: hidden; min-width: 180px; max-width: 280px; padding: 5px 0 5px 7px; } .right-panel { background-color: white; overflow: hidden; padding: 5px 5px 5px 5px; -webkit-flex: 1; flex: 1; flex-basis: auto; } .left-panel > .page-nav > .page-tab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: solid 1px rgba(245, 245, 245, 0.4); box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3) inset; border-top-width: 1px; border-right-width: 0; padding: 0 5px; margin-bottom: 0px; cursor: pointer; height: 25px; text-transform: uppercase; font-weight: bold; font-size: 11px; list-style: none; text-align: center; } .left-panel > .page-nav > .page-tab.active { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* Standard syntax; must be last */ } .left-panel > .page-nav > .page-tab.active:after { content: " "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; margin-right: -5px; display: inline-block; float: right; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } ``` JSFiddle link: <http://jsfiddle.net/LvG2C/>
2013/06/16
[ "https://Stackoverflow.com/questions/17138785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1581233/" ]
*Alternative solution keeping float in the run* Using line-height value + font-size to set size of arrow and margin. <http://jsfiddle.net/LvG2C/3/> **edit:** what follows is **not compatible with text-ellipsis** if you turn **`<a>`** as one inline-block. you use float. it is not compatible with vertical-align. You can set as inline-box and the arrow too to vertical-align them mutually. give a width to a to push arrow all the way : <http://jsfiddle.net/LvG2C/1/> ``` .left-panel > .page-nav > .page-tab.active:after { content:" "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; vertical-align:middle; display: inline-block; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } a { display:inline-block; width:100%; vertical-align:middle; margin-right:-3px; } ```
Nice use of CSS3 there. If your client is okay with you using cSS3 then your method suffices (if it isn't the best option out there). However, I work for clients that require the use of legacy browsers and as a matter of fact my work still actively uses IE7/8. This is the approach I would employ for a simple arrow styling solution. It is simple, robust, and compatible with IE5+. IN addition, this method will work beautifully on mobile devices and tablet browsers. (Know your customers/client needs and decide if you want to fall back on this method). 1. Create the arrow in photoshop and save it as a .png . The file should only be 50bytes or something ridiculously small. (5px X 10px). 2. Create the gradient in photoshop as well. It should be (1px wide) and the height should match be exactly two times that of an li element. Create a normal / hover state on the image. So the first y pixels should be normal gradient and the next y pixels should be hover over gradient. We will use css to change the positioning of the background. NO reason to create 2 gradient images. 3. Deploy CSS2. li { background: url(gradient.png) repeat-x; height: 30px; line-height: 30px; text-align: center; color: #000; font-size: 14px; } li:hover { background-position: 0 -30px; } li a { background: url(arrow.png) no-repeat 100% center; } This should get you started. And show you an alternative approach. ### SO is bugging out and can't get the code to code block to format
17,138,785
As the title says, I am trying to center vertically a CSS triangle/arrow onto the right side of a div, and of course, I am looking to do this using a pure CSS solution. I would have included pictures, but because of my low-rep, I can't. Note: My current code isn't working properly and is not cross-browser compatible (i.e. Chrome puts the arrow on the top right~ but on Firefox, it gets squished down outside the bounds) **My code** *HTML*: ``` <div class="main-panel"> <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> <div class="right-panel"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque nisl vitae nulla dignissim, at rutrum nunc interdum. Mauris et facilisis orci. Phasellus ac libero id nisl malesuada ultricies. Aenean vitae cursus velit. Nulla sit amet leo eu enim scelerisque volutpat. Vivamus gravida felis et pulvinar mollis. Sed bibendum consectetur nisi, sit amet tincidunt enim interdum a. Duis sed gravida felis. Fusce mauris est, bibendum a neque et, fringilla placerat magna. Vestibulum pellentesque massa quis bibendum dapibus. Praesent pharetra ipsum id libero dapibus rutrum. Quisque accumsan dictum lacinia. Mauris ut mi nec orci accumsan consequat. Donec blandit augue eget nulla fermentum, quis porttitor lacus feugiat. Proin vehicula dolor id lorem egestas elementum. Nullam vitae rutrum tortor. Proin varius adipiscing nibh. Vivamus ultrices nibh nec varius bibendum. Integer quis nisi sed metus adipiscing sagittis. Curabitur congue, nisi nec pretium suscipit, mi leo posuere dui, pellentesque dapibus ligula urna a ligula. Quisque mauris nisl, interdum eu est in, elementum cursus arcu. Sed suscipit vel erat vitae viverra. Mauris neque ipsum, bibendum eget hendrerit ac, vulputate in eros. Ut tincidunt, urna ac auctor porttitor, mauris purus varius erat, ut pellentesque urna turpis non nibh. Aenean sed neque a velit tristique tristique. Praesent id cursus libero. Vestibulum pulvinar feugiat neque pretium suscipit. Nam vitae magna eget elit aliquam accumsan. Duis et eleifend enim. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec nunc est, commodo quis pretium vitae, lacinia ac lectus. Cras mi tellus, suscipit non leo eget, auctor feugiat mauris. Praesent vitae vehicula ipsum, nec ultrices arcu. Proin mollis leo sit amet erat scelerisque feugiat. Nullam eget varius ante. Praesent a laoreet libero. Suspendisse ut eros et odio rhoncus malesuada. Integer laoreet, leo at fringilla volutpat, augue lorem tincidunt augue, sit amet feugiat erat neque in est. Phasellus imperdiet, nisi vel faucibus auctor, sapien orci mollis est, tincidunt vehicula nisi nunc sit amet purus. Sed cursus ipsum nisi, id elementum leo feugiat in. Phasellus vitae arcu ac ligula pellentesque malesuada. Maecenas vulputate nunc et consequat pellentesque. Nulla semper quam a orci eleifend, vel gravida est euismod. Nam fermentum, nisi ullamcorper congue convallis, turpis purus lacinia ligula, ac posuere urna est non felis. Cras lobortis ligula neque, vel fermentum magna facilisis sit amet. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque a quam nec sem vestibulum dapibus quis non lacus. Integer eget ligula eu turpis pretium iaculis. Cras gravida ligula in mauris bibendum placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ac tristique risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque diam nisi, sodales vel nisi a, sollicitudin commodo ipsum. Fusce elementum nisi ac semper dignissim. Etiam nec felis dapibus lacus faucibus vehicula eget eu odio. Sed id risus tellus. Curabitur in luctus orci. </p> </div> </div> ``` *CSS*: ``` * { margin: 0; padding: 0; font-family: "Helvetica Neue",Helvetica,sans-serif; line-height: 20px; } .main-panel { min-width: 700px; width: 100%; min-height: 500px; max-height: 700px; display: -webkit-flex; display: flex; background: rgba(64, 64, 64, 0.4); } .left-panel { border-width: 2px 0 0 0 0; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(245, 245, 245, 0.4), rgba(221, 221, 221, 0.4)); /* Standard syntax; must be last */ box-shadow: 0px 0px 7px white inset; -moz-box-shadow: 0px 0px 7px white inset; -webkit-box-shadow: 0px 0px 7px white inset; overflow: hidden; min-width: 180px; max-width: 280px; padding: 5px 0 5px 7px; } .right-panel { background-color: white; overflow: hidden; padding: 5px 5px 5px 5px; -webkit-flex: 1; flex: 1; flex-basis: auto; } .left-panel > .page-nav > .page-tab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: solid 1px rgba(245, 245, 245, 0.4); box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3) inset; border-top-width: 1px; border-right-width: 0; padding: 0 5px; margin-bottom: 0px; cursor: pointer; height: 25px; text-transform: uppercase; font-weight: bold; font-size: 11px; list-style: none; text-align: center; } .left-panel > .page-nav > .page-tab.active { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; background: rgba(245, 245, 245, 0.4); /* fallback color if gradients are not supported */ background: -webkit-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For Chrome and Safari */ background: -moz-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Fx (3.6 to 15) */ background: -ms-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For pre-releases of IE 10*/ background: -o-linear-gradient(top, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* For old Opera (11.1 to 12.0) */ background: linear-gradient(to center bottom, rgba(68, 68, 68, 0.4), rgba(59, 59, 59, 0.4)); /* Standard syntax; must be last */ } .left-panel > .page-nav > .page-tab.active:after { content: " "; height: 0; width: 0; border-top: 7px solid transparent; border-bottom: 7px solid transparent; border-right: 7px solid white; margin-right: -5px; display: inline-block; float: right; } .left-panel > .page-nav > .page-tab:hover { box-shadow: 2px 2px 2px rgba(245, 245, 245, 0.6) inset; } ``` JSFiddle link: <http://jsfiddle.net/LvG2C/>
2013/06/16
[ "https://Stackoverflow.com/questions/17138785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1581233/" ]
An alternative would be to set a class on the elements that you wish to have an arrow on the left side centered vertically. In the class would look something like: ``` .left-arrow { background: url('/images/arrow.png') 0% 50% no-repeat; padding-left: 20px; // Number of pixels you need to offset the content to make the content come after the arrow the way you want it to. } ``` This would mean that any element with a class="left-arrow" attribute would have an arrow centered vertically on the left side. Then the nav code would look like: ``` <nav class="left-panel"> <ul class="page-nav"> <li class="page-tab active"><a class="page-nav-link">Dashboard</a></li> <li class="page-tab"><a class="page-nav-link">Page 1</a></li> <li class="page-tab"><a class="page-nav-link">Page 2</a></li> <li class="page-tab"><a class="page-nav-link">Page 3</a></li> <li class="page-tab"><a class="page-nav-link left-arrow">Somewhat long</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abc</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdef</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghi</a></li> <li class="page-tab"><a class="page-nav-link">Somewhat long abcdefghijkl</a></li> <li class="page-tab"><a class="page-nav-link">Very long element abcdefghijklmno</a></li> </ul> </nav> ```
Nice use of CSS3 there. If your client is okay with you using cSS3 then your method suffices (if it isn't the best option out there). However, I work for clients that require the use of legacy browsers and as a matter of fact my work still actively uses IE7/8. This is the approach I would employ for a simple arrow styling solution. It is simple, robust, and compatible with IE5+. IN addition, this method will work beautifully on mobile devices and tablet browsers. (Know your customers/client needs and decide if you want to fall back on this method). 1. Create the arrow in photoshop and save it as a .png . The file should only be 50bytes or something ridiculously small. (5px X 10px). 2. Create the gradient in photoshop as well. It should be (1px wide) and the height should match be exactly two times that of an li element. Create a normal / hover state on the image. So the first y pixels should be normal gradient and the next y pixels should be hover over gradient. We will use css to change the positioning of the background. NO reason to create 2 gradient images. 3. Deploy CSS2. li { background: url(gradient.png) repeat-x; height: 30px; line-height: 30px; text-align: center; color: #000; font-size: 14px; } li:hover { background-position: 0 -30px; } li a { background: url(arrow.png) no-repeat 100% center; } This should get you started. And show you an alternative approach. ### SO is bugging out and can't get the code to code block to format
7,567,333
I am stuck at this point. Scenario is like that - I have already uploaded my application in apple Appstore and reflecting status is "Ready for sale",This is great. but there is one issue,now i want to update the binary file. How should i go around it? can anyone help me out ? Thanking you in advance ...
2011/09/27
[ "https://Stackoverflow.com/questions/7567333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/820700/" ]
There is no such option available.you can save file in to sdcard or any external storage c the code i have done for saving image in external storage. ``` public void onClick(View v) { if(v == imgForPhotograph) { path = Environment.getExternalStorageDirectory() + "/photo1.jpg"; File file = new File(path); Uri outputFileUri = Uri.fromFile(file); Intent intent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY); } } public void onActivityResult(int requestCode, int resultCode, Intent data) { System.gc(); if (requestCode == CAPTURE_IMAGE_ACTIVITY) { if (resultCode == Activity.RESULT_OK) { try { // Call function MakeFolder to create folder structure if // its not created if(imageBitmap != null) { imageBitmap = null; imageBitmap.recycle(); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 3; imageBitmap = BitmapFactory.decodeFile(path, options); ByteArrayOutputStream baos = new ByteArrayOutputStream(); imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); // bm byte[] bmpbyte = baos.toByteArray(); // Imagebase64= Base64.encodeToString(bmpbyte, Base64.DEFAULT); // set imgForPhotograph.setImageBitmap(imageBitmap); isImageTaken = true; // Name for image IMAGEPATH = getString(R.string.Image) + System.currentTimeMillis(); SaveImageFile(imageBitmap,IMAGEPATH); } catch (Exception e) { Toast.makeText(this, "Picture Not taken", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } } ``` } All The Best....
``` Button btnCam=(Button)findViewById(R.id.camBtn); btnCam.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Intent detailActivity = new Intent(getBaseContext(),com.rodasys.profile.detailProfile.class); //startActivity(detailActivity); saveImage(); } }); } public void saveImage() { try { FileOutputStream fos = openFileOutput("MyFile.jpeg", Context.MODE_WORLD_WRITEABLE); fos.close(); File f = new File(getFilesDir() + File.separator + "MyFile.jpeg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,90); startActivityForResult(intent,IMAGE_CAPTURE); //startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)),IMAGE_CAPTURE); } catch(IOException e) { } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { if (resultCode == RESULT_OK){ finish(); //imageView=(ImageView)findViewById(R.id.imageView1); //imageView.setImageURI(imageUri); Intent detActivity = new Intent(getBaseContext(),com.rodasys.profile.detailProfile.class); startActivity(detActivity); //Log.d("ANDRO_CAMERA","Picture taken!!!"); // } } } ``` IN DETAIL PROFILE ACTIVITY public class detailProfile extends Activity{ ``` String fname=new File(getFilesDir(),"MyFile.jpeg").getAbsolutePath(); ``` //USING THIS FILE PATH YOU CAN LOAD THE IMAGE IN THIS ACTIVITY } YOU HAVE ANOTHER OPTION YOU CAN PASS THE IMAGE TO THROUGH THE INTENT AT THE TIME OF CREATING THE NEW INTENT AND AFTER THAT YOU CAN ACCESS THAT IMAGE THROUGH THE BUNDLE OBJECT IN THE NEW INTENT. bytes[] imgs = ... // your image Intent intent = new Intent(this, YourActivity.class); intent.putExtra("img", imgs); startActivity(intent) in detailprofile bytes[] receiver = getIntent().getExtra("imgs"); //using Byte array you can display your image in ur imageview
7,567,333
I am stuck at this point. Scenario is like that - I have already uploaded my application in apple Appstore and reflecting status is "Ready for sale",This is great. but there is one issue,now i want to update the binary file. How should i go around it? can anyone help me out ? Thanking you in advance ...
2011/09/27
[ "https://Stackoverflow.com/questions/7567333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/820700/" ]
There is no such option available.you can save file in to sdcard or any external storage c the code i have done for saving image in external storage. ``` public void onClick(View v) { if(v == imgForPhotograph) { path = Environment.getExternalStorageDirectory() + "/photo1.jpg"; File file = new File(path); Uri outputFileUri = Uri.fromFile(file); Intent intent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY); } } public void onActivityResult(int requestCode, int resultCode, Intent data) { System.gc(); if (requestCode == CAPTURE_IMAGE_ACTIVITY) { if (resultCode == Activity.RESULT_OK) { try { // Call function MakeFolder to create folder structure if // its not created if(imageBitmap != null) { imageBitmap = null; imageBitmap.recycle(); } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 3; imageBitmap = BitmapFactory.decodeFile(path, options); ByteArrayOutputStream baos = new ByteArrayOutputStream(); imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); // bm byte[] bmpbyte = baos.toByteArray(); // Imagebase64= Base64.encodeToString(bmpbyte, Base64.DEFAULT); // set imgForPhotograph.setImageBitmap(imageBitmap); isImageTaken = true; // Name for image IMAGEPATH = getString(R.string.Image) + System.currentTimeMillis(); SaveImageFile(imageBitmap,IMAGEPATH); } catch (Exception e) { Toast.makeText(this, "Picture Not taken", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } } ``` } All The Best....
Hi guys, this code is working. For camera and stored into sd card: ``` public class CampicsaveActivity extends Activity { /** Called when the activity is first created. */ FrameLayout frm; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); frm=(FrameLayout)findViewById(R.id.preview); Button btnCam=(Button)findViewById(R.id.buttonClick); btnCam.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Intent detailActivity = new Intent(getBaseContext(),com.rodasys.profile.detailProfile.class); // startActivity(detailActivity); saveImage(0); } }); } public void saveImage(int IMAGE_CAPTURE) { try { FileOutputStream fos = openFileOutput("MyFile.jpeg", Context.MODE_WORLD_WRITEABLE); fos.close(); File f = new File(getFilesDir() + File.separator + "MyFile.jpeg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,90); startActivityForResult(intent,IMAGE_CAPTURE); //startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)),IMAGE_CAPTURE); } catch(IOException e) {;} } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { if (resultCode == RESULT_OK) { finish(); //imageView=(ImageView)findViewById(R.id.imageView1); //imageView.setImageURI(imageUri); Intent detActivity = new Intent(getBaseContext(),CampicsaveActivity.class); startActivity(detActivity); //Log.d("ANDRO_CAMERA","Picture taken!!!"); // } } } } } ```
7,567,333
I am stuck at this point. Scenario is like that - I have already uploaded my application in apple Appstore and reflecting status is "Ready for sale",This is great. but there is one issue,now i want to update the binary file. How should i go around it? can anyone help me out ? Thanking you in advance ...
2011/09/27
[ "https://Stackoverflow.com/questions/7567333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/820700/" ]
``` Button btnCam=(Button)findViewById(R.id.camBtn); btnCam.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Intent detailActivity = new Intent(getBaseContext(),com.rodasys.profile.detailProfile.class); //startActivity(detailActivity); saveImage(); } }); } public void saveImage() { try { FileOutputStream fos = openFileOutput("MyFile.jpeg", Context.MODE_WORLD_WRITEABLE); fos.close(); File f = new File(getFilesDir() + File.separator + "MyFile.jpeg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,90); startActivityForResult(intent,IMAGE_CAPTURE); //startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)),IMAGE_CAPTURE); } catch(IOException e) { } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { if (resultCode == RESULT_OK){ finish(); //imageView=(ImageView)findViewById(R.id.imageView1); //imageView.setImageURI(imageUri); Intent detActivity = new Intent(getBaseContext(),com.rodasys.profile.detailProfile.class); startActivity(detActivity); //Log.d("ANDRO_CAMERA","Picture taken!!!"); // } } } ``` IN DETAIL PROFILE ACTIVITY public class detailProfile extends Activity{ ``` String fname=new File(getFilesDir(),"MyFile.jpeg").getAbsolutePath(); ``` //USING THIS FILE PATH YOU CAN LOAD THE IMAGE IN THIS ACTIVITY } YOU HAVE ANOTHER OPTION YOU CAN PASS THE IMAGE TO THROUGH THE INTENT AT THE TIME OF CREATING THE NEW INTENT AND AFTER THAT YOU CAN ACCESS THAT IMAGE THROUGH THE BUNDLE OBJECT IN THE NEW INTENT. bytes[] imgs = ... // your image Intent intent = new Intent(this, YourActivity.class); intent.putExtra("img", imgs); startActivity(intent) in detailprofile bytes[] receiver = getIntent().getExtra("imgs"); //using Byte array you can display your image in ur imageview
Hi guys, this code is working. For camera and stored into sd card: ``` public class CampicsaveActivity extends Activity { /** Called when the activity is first created. */ FrameLayout frm; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); frm=(FrameLayout)findViewById(R.id.preview); Button btnCam=(Button)findViewById(R.id.buttonClick); btnCam.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Intent detailActivity = new Intent(getBaseContext(),com.rodasys.profile.detailProfile.class); // startActivity(detailActivity); saveImage(0); } }); } public void saveImage(int IMAGE_CAPTURE) { try { FileOutputStream fos = openFileOutput("MyFile.jpeg", Context.MODE_WORLD_WRITEABLE); fos.close(); File f = new File(getFilesDir() + File.separator + "MyFile.jpeg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,90); startActivityForResult(intent,IMAGE_CAPTURE); //startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)),IMAGE_CAPTURE); } catch(IOException e) {;} } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 0) { if (resultCode == RESULT_OK) { finish(); //imageView=(ImageView)findViewById(R.id.imageView1); //imageView.setImageURI(imageUri); Intent detActivity = new Intent(getBaseContext(),CampicsaveActivity.class); startActivity(detActivity); //Log.d("ANDRO_CAMERA","Picture taken!!!"); // } } } } } ```
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
``` getcwd(); ``` or ``` dirname(__FILE__); ``` or (PHP5) ``` basename(__DIR__) ``` <http://php.net/manual/en/function.getcwd.php> <http://php.net/manual/en/function.dirname.php> You can use `basename()` to get the trailing part of the path :) In your case, I'd say you are most likely looking to use `getcwd()`, `dirname(__FILE__)` is more useful when you have a file that needs to include another library and is included in another library. Eg: ``` main.php libs/common.php libs/images/editor.php ``` In your `common.php` you need to use functions in `editor.php`, so you use `common.php`: ``` require_once dirname(__FILE__) . '/images/editor.php'; ``` `main.php`: ``` require_once libs/common.php ``` That way when common.php is `require'd` in `main.php`, the call of `require_once` in `common.php` will correctly includes `editor.php` in `images/editor.php` instead of trying to look in current directory where `main.php` is run.
basename(getcwd()); // returns only the current working dir name.
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
Actually I found the best solution is the following: ``` $cur_dir = explode('\\', getcwd()); echo $cur_dir[count($cur_dir)-1]; ``` if your dir is www\var\path\ **Current\_Path** then this returns **Current\_path**
basename(getcwd()); // returns only the current working dir name.
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
You can use `dirname(__FILE__)` to get the path to the directory of the current file. Example: `/path_to/your_dir/your_file.php`: ```php // use dirname to get the directory of the current file $path = dirname(__FILE__); // $path here is now /path_to/your_dir // split directory into array of pieces $pieces = explode(DIRECTORY_SEPARATOR, $path); // $pieces = ['path_to', 'your_dir'] // get the last piece echo $pieces[count($pieces) - 1]; // result is: your_dir ```
I use this line to get the actual file directory name without the path. (For windows) ``` substr(dirname(__FILE__), strrpos(dirname(__FILE__), '\\') + 1) ``` I changed it a bit to work on Linux also ``` substr(dirname(__FILE__), strrpos(str_replace('\\', '/', dirname(__FILE__)), '/') + 1) ```
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
To get only the name of the directory where script executed: ``` //Path to script: /data/html/cars/index.php echo basename(dirname(__FILE__)); //"cars" ```
I use this line to get the actual file directory name without the path. (For windows) ``` substr(dirname(__FILE__), strrpos(dirname(__FILE__), '\\') + 1) ``` I changed it a bit to work on Linux also ``` substr(dirname(__FILE__), strrpos(str_replace('\\', '/', dirname(__FILE__)), '/') + 1) ```
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
You can use `dirname(__FILE__)` to get the path to the directory of the current file. Example: `/path_to/your_dir/your_file.php`: ```php // use dirname to get the directory of the current file $path = dirname(__FILE__); // $path here is now /path_to/your_dir // split directory into array of pieces $pieces = explode(DIRECTORY_SEPARATOR, $path); // $pieces = ['path_to', 'your_dir'] // get the last piece echo $pieces[count($pieces) - 1]; // result is: your_dir ```
To get the names of current directory we can use `getcwd()` or `dirname(__FILE__)` but `getcwd()` and `dirname(__FILE__)` are not synonymous. They do exactly what their names are. If your code is running by referring a class in another file which exists in some other directory then these both methods will return different results. For example if I am calling a class, from where these two functions are invoked and the class exists in some `/controller/goodclass.php` from `/index.php` then **`getcwd()` will return `'/`** and **`dirname(__FILE__)` will return `/controller`**.
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
``` getcwd(); ``` or ``` dirname(__FILE__); ``` or (PHP5) ``` basename(__DIR__) ``` <http://php.net/manual/en/function.getcwd.php> <http://php.net/manual/en/function.dirname.php> You can use `basename()` to get the trailing part of the path :) In your case, I'd say you are most likely looking to use `getcwd()`, `dirname(__FILE__)` is more useful when you have a file that needs to include another library and is included in another library. Eg: ``` main.php libs/common.php libs/images/editor.php ``` In your `common.php` you need to use functions in `editor.php`, so you use `common.php`: ``` require_once dirname(__FILE__) . '/images/editor.php'; ``` `main.php`: ``` require_once libs/common.php ``` That way when common.php is `require'd` in `main.php`, the call of `require_once` in `common.php` will correctly includes `editor.php` in `images/editor.php` instead of trying to look in current directory where `main.php` is run.
Actually I found the best solution is the following: ``` $cur_dir = explode('\\', getcwd()); echo $cur_dir[count($cur_dir)-1]; ``` if your dir is www\var\path\ **Current\_Path** then this returns **Current\_path**
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
``` getcwd(); ``` or ``` dirname(__FILE__); ``` or (PHP5) ``` basename(__DIR__) ``` <http://php.net/manual/en/function.getcwd.php> <http://php.net/manual/en/function.dirname.php> You can use `basename()` to get the trailing part of the path :) In your case, I'd say you are most likely looking to use `getcwd()`, `dirname(__FILE__)` is more useful when you have a file that needs to include another library and is included in another library. Eg: ``` main.php libs/common.php libs/images/editor.php ``` In your `common.php` you need to use functions in `editor.php`, so you use `common.php`: ``` require_once dirname(__FILE__) . '/images/editor.php'; ``` `main.php`: ``` require_once libs/common.php ``` That way when common.php is `require'd` in `main.php`, the call of `require_once` in `common.php` will correctly includes `editor.php` in `images/editor.php` instead of trying to look in current directory where `main.php` is run.
To get the names of current directory we can use `getcwd()` or `dirname(__FILE__)` but `getcwd()` and `dirname(__FILE__)` are not synonymous. They do exactly what their names are. If your code is running by referring a class in another file which exists in some other directory then these both methods will return different results. For example if I am calling a class, from where these two functions are invoked and the class exists in some `/controller/goodclass.php` from `/index.php` then **`getcwd()` will return `'/`** and **`dirname(__FILE__)` will return `/controller`**.
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
You can use `dirname(__FILE__)` to get the path to the directory of the current file. Example: `/path_to/your_dir/your_file.php`: ```php // use dirname to get the directory of the current file $path = dirname(__FILE__); // $path here is now /path_to/your_dir // split directory into array of pieces $pieces = explode(DIRECTORY_SEPARATOR, $path); // $pieces = ['path_to', 'your_dir'] // get the last piece echo $pieces[count($pieces) - 1]; // result is: your_dir ```
Actually I found the best solution is the following: ``` $cur_dir = explode('\\', getcwd()); echo $cur_dir[count($cur_dir)-1]; ``` if your dir is www\var\path\ **Current\_Path** then this returns **Current\_path**
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
``` echo basename(__DIR__); will return the current directory name only echo basename(__FILE__); will return the current file name only ```
To get the names of current directory we can use `getcwd()` or `dirname(__FILE__)` but `getcwd()` and `dirname(__FILE__)` are not synonymous. They do exactly what their names are. If your code is running by referring a class in another file which exists in some other directory then these both methods will return different results. For example if I am calling a class, from where these two functions are invoked and the class exists in some `/controller/goodclass.php` from `/index.php` then **`getcwd()` will return `'/`** and **`dirname(__FILE__)` will return `/controller`**.
9,997,391
I have a php page inside a folder on my website. I need to add the name of the current directory into a variable for example: ``` $myVar = current_directory_name; ``` Is this possible?
2012/04/03
[ "https://Stackoverflow.com/questions/9997391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/683553/" ]
``` echo basename(__DIR__); will return the current directory name only echo basename(__FILE__); will return the current file name only ```
I use this line to get the actual file directory name without the path. (For windows) ``` substr(dirname(__FILE__), strrpos(dirname(__FILE__), '\\') + 1) ``` I changed it a bit to work on Linux also ``` substr(dirname(__FILE__), strrpos(str_replace('\\', '/', dirname(__FILE__)), '/') + 1) ```
40,060,961
I wonder whether it is possible to send an image via message in iMessageExtension. I am developing an app where sender and receiver need to see the same image. Basically here is DetailViewController with ImageView and ImageView.image should image sent via message.
2016/10/15
[ "https://Stackoverflow.com/questions/40060961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2396575/" ]
`randint` does not act like the rest of Python (for historical reasons relating to other computer languages). In particular, `randint()` *does* include the upper bound, unlike Python's list indices and `len()`. So use `randint(0,len(self.AI_Greeted) - 1)`.
That is because list indexes start at `0` and `randint` will choose a number in the range you specify `inclusively` with the upper bound. Observe this example: ``` >>> a = [1,2,3] >>> len(a) 3 ``` So, now try to get the value at index `3`: ``` >>> a[3] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range ``` Because the highest index is actually `2`. What you want to do in your example is simply `-1` the length: ``` random.randint(0,len(self.AI_Greeted) - 1) ```
2,485,011
I use the image attachment page to show images attached to a post one by one, in a slideshow sort of affect. I'd like to be able to display the total number of images attached to the parent post and the number of the particular image that's being shown on any given attachment page so you see the picture and the words **"Image 3 of 15"** for example. **Update...** I was able to get the total number to show using this code: ``` <?php global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); echo $count; ?> ``` I still can't figure out how to show the number of the current image. Anyone have any suggestions? **Update 2...** Greenie's answer got me almost there but it's outputting all the numbers at once: > > "Image 1 of 8Image 2 of 8Image 3 of > 8Image 4 of 8Image 5 of 8Image 6 of > 8Image 7 of 8Image 8 of 8" > > > Here is the code I used: ``` global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); $currentImage = 1; foreach ($attachments as $attachment) { // output your image here echo "Image ". $currentImage . " of ". $count; $currentImage++; } ``` What's going wrong? **Update 3 - THE ANSWER!** ``` global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); $specific = array(); $i = 1; foreach ( $attachments as $attachment ) { $specific[$attachment->ID] = $i; ++$i; } echo "Image {$specific[$post->ID]} of {$count}"; ```
2010/03/20
[ "https://Stackoverflow.com/questions/2485011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296890/" ]
This works: ``` global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); $specific = array(); $i = 1; foreach ( $attachments as $attachment ) { $specific[$attachment->ID] = $i; ++$i; } echo "Image {$specific[$post->ID]} of {$count}"; ```
Add something like this to the above code: ``` $currentImage = 1; foreach ($attachments as $attachment) { // output your image here echo "Image ". $currentImage . " of ". $count; $currentImage++; } ```
2,485,011
I use the image attachment page to show images attached to a post one by one, in a slideshow sort of affect. I'd like to be able to display the total number of images attached to the parent post and the number of the particular image that's being shown on any given attachment page so you see the picture and the words **"Image 3 of 15"** for example. **Update...** I was able to get the total number to show using this code: ``` <?php global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); echo $count; ?> ``` I still can't figure out how to show the number of the current image. Anyone have any suggestions? **Update 2...** Greenie's answer got me almost there but it's outputting all the numbers at once: > > "Image 1 of 8Image 2 of 8Image 3 of > 8Image 4 of 8Image 5 of 8Image 6 of > 8Image 7 of 8Image 8 of 8" > > > Here is the code I used: ``` global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); $currentImage = 1; foreach ($attachments as $attachment) { // output your image here echo "Image ". $currentImage . " of ". $count; $currentImage++; } ``` What's going wrong? **Update 3 - THE ANSWER!** ``` global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); $specific = array(); $i = 1; foreach ( $attachments as $attachment ) { $specific[$attachment->ID] = $i; ++$i; } echo "Image {$specific[$post->ID]} of {$count}"; ```
2010/03/20
[ "https://Stackoverflow.com/questions/2485011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/296890/" ]
This works: ``` global $post; $attachments = get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); $count = count( $attachments ); $specific = array(); $i = 1; foreach ( $attachments as $attachment ) { $specific[$attachment->ID] = $i; ++$i; } echo "Image {$specific[$post->ID]} of {$count}"; ```
If you are looking for a plugin to manage image gallery, you can use `attachments` plugin, <http://wordpress.org/plugins/attachments/> It keeps the gallery separate and does not put the image gallery shortcodes in post content, thus providing you with full hold over image display in your post/page/custom post. You can also change the order of your images by just drag-n-drop here is a sample code of how to retrieve your gallery images, ``` <?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?> <?php if( $attachments->exist() ) : ?> <h3>Attachments</h3> <p>Total Attachments: <?php echo $attachments->total(); ?></p> <ul> <?php while( $attachments->get() ) : ?> <li> ID: <?php echo $attachments->id(); ?><br /> Type: <?php echo $attachments->type(); ?><br /> Subtype: <?php echo $attachments->subtype(); ?><br /> URL: <?php echo $attachments->url(); ?><br /> Image: <?php echo $attachments->image( 'thumbnail' ); ?><br /> Source: <?php echo $attachments->src( 'full' ); ?><br /> Size: <?php echo $attachments->filesize(); ?><br /> Title Field: <?php echo $attachments->field( 'title' ); ?><br /> Caption Field: <?php echo $attachments->field( 'caption' ); ?> </li> <?php endwhile; ?> </ul> <?php endif; ?> ```
40,020,013
I have not used javascript that much, so I'm confuse about the following code structure. The code is from an external javascript file and the init function was called from index page as "windows.Ux.init(xxx)". I know it's self-invoking function and I assume "windows" object is passed as a parameter to that function. And I assume "exports.Ux" line declares name space and assigned functions to the two variables in the namespace. Are my assumptions correct? ``` ( function( exports ) { ... function init(x) { ... } .. exports.Ux = { init: init, clear: clear }; })( window ); ```
2016/10/13
[ "https://Stackoverflow.com/questions/40020013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3742750/" ]
When using `ngOptions` you can use `track by` to determine an unique identifier to bind value properly. Also, the value mustn't be a string, it have to be an object like so: ``` $scope.data3 = { templateId :"001" , color : "yellow"}; ``` And your template: ``` <select name="third" ng-model="data3" ng-options="value as key for (key, value) in options track by value.templateId"> <option value="">Select template</option> </select> ``` Using `track by value.templateId` will tell `ngOptions` to look at the property `value.templateId` when testing the equality of the objects and determine selected value. Updated your [fiddle](http://jsfiddle.net/pcfLn4xg/7/).
In order to achieve this requirement you have to use track by in ng-select. The track by will help you in binding the select option with a value tag. You should also provide an Unique Id field to track the select option. ``` <select ng-model="data" ng-options="item.color for item in options track by item.templateId"> </select> ``` In your controller the options object will be like this ``` $scope.options = [{ templateId :"001" , color : "yellow"}, { templateId :"002" , color : "red"} , { templateId :"003" , color : "green"}]; ``` In order to initialize the select option you can set the model by ``` $scope.data= $scope.options[0]; ``` You can initialize the scope variable only if you use the track by property in select option. In your question the `templateId` is the unique id
22,476,415
i have a list item and i would like to style 2 (or more) text views in one line. ``` ------------------------------------------------ | | | TEXT_VIEW_1: FOO TEXT_VIEW_2: BAR | | | | | ------------------------------------------------ ``` How to do it most simple and effective? Thanks for any advice.
2014/03/18
[ "https://Stackoverflow.com/questions/22476415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535556/" ]
Create your list item layout as below... ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="FOO" /> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="BAR" /> </LinearLayout> ``` If you want to have more than 2 `TextView` then just add `android:layout_weight="1"` attribute to them. If all `TextView` contains `android:layout_weight="1"` then this attribute will distribute layout width equally to all `Textviews`.
It's all explained in this thread. You just need to modify XML that textviews are side by side and you are done: [Android custom Row Item for ListView](https://stackoverflow.com/questions/15832335/android-custom-row-item-for-listview)
22,476,415
i have a list item and i would like to style 2 (or more) text views in one line. ``` ------------------------------------------------ | | | TEXT_VIEW_1: FOO TEXT_VIEW_2: BAR | | | | | ------------------------------------------------ ``` How to do it most simple and effective? Thanks for any advice.
2014/03/18
[ "https://Stackoverflow.com/questions/22476415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535556/" ]
Create your list item layout as below... ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="FOO" /> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="BAR" /> </LinearLayout> ``` If you want to have more than 2 `TextView` then just add `android:layout_weight="1"` attribute to them. If all `TextView` contains `android:layout_weight="1"` then this attribute will distribute layout width equally to all `Textviews`.
Use orientation of LinearLayout as Horizontal: and provide weights: ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="3" > <TextView android:id="@+id/textView1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Text1" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/textView2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Text2" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/textView3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Text3" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> ```
22,476,415
i have a list item and i would like to style 2 (or more) text views in one line. ``` ------------------------------------------------ | | | TEXT_VIEW_1: FOO TEXT_VIEW_2: BAR | | | | | ------------------------------------------------ ``` How to do it most simple and effective? Thanks for any advice.
2014/03/18
[ "https://Stackoverflow.com/questions/22476415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535556/" ]
Create your list item layout as below... ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="FOO" /> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="BAR" /> </LinearLayout> ``` If you want to have more than 2 `TextView` then just add `android:layout_weight="1"` attribute to them. If all `TextView` contains `android:layout_weight="1"` then this attribute will distribute layout width equally to all `Textviews`.
use below code for list item. ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightsum="2" > <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="FOO" /> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="BAR" /> </LinearLayout> ``` And make both textview singleLine true.
22,476,415
i have a list item and i would like to style 2 (or more) text views in one line. ``` ------------------------------------------------ | | | TEXT_VIEW_1: FOO TEXT_VIEW_2: BAR | | | | | ------------------------------------------------ ``` How to do it most simple and effective? Thanks for any advice.
2014/03/18
[ "https://Stackoverflow.com/questions/22476415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535556/" ]
Use orientation of LinearLayout as Horizontal: and provide weights: ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="3" > <TextView android:id="@+id/textView1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Text1" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/textView2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Text2" android:textAppearance="?android:attr/textAppearanceMedium" /> <TextView android:id="@+id/textView3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="Text3" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> ```
It's all explained in this thread. You just need to modify XML that textviews are side by side and you are done: [Android custom Row Item for ListView](https://stackoverflow.com/questions/15832335/android-custom-row-item-for-listview)
22,476,415
i have a list item and i would like to style 2 (or more) text views in one line. ``` ------------------------------------------------ | | | TEXT_VIEW_1: FOO TEXT_VIEW_2: BAR | | | | | ------------------------------------------------ ``` How to do it most simple and effective? Thanks for any advice.
2014/03/18
[ "https://Stackoverflow.com/questions/22476415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/535556/" ]
use below code for list item. ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightsum="2" > <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="FOO" /> <TextView android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="BAR" /> </LinearLayout> ``` And make both textview singleLine true.
It's all explained in this thread. You just need to modify XML that textviews are side by side and you are done: [Android custom Row Item for ListView](https://stackoverflow.com/questions/15832335/android-custom-row-item-for-listview)
52,259,142
I have the form for date filter and I trying set the default value for the start and end date for date inputs. ``` <form [formGroup]="filter" (ngSubmit)="applyFilter()"> <mat-form-field> <input matInput [matDatepicker]="start" formControlName="start" placeholder="Начальная дата"> <mat-datepicker-toggle matSuffix [for]="start"></mat-datepicker-toggle> <mat-datepicker #start></mat-datepicker> </mat-form-field> <mat-form-field> <input matInput [matDatepicker]="end" formControlName="end" placeholder="Конечная дата"> <mat-datepicker-toggle matSuffix [for]="end"></mat-datepicker-toggle> <mat-datepicker #end></mat-datepicker> </mat-form-field> ``` And TS part ``` refreshFilter() { const now = new Date(); const monthAgo = new Date().setMonth(now.getMonth() - 1).toString(); console.log(monthAgo) console.log(now) this.filter = new FormGroup({ start: new FormControl(monthAgo, []), end: new FormControl(now, []) }); ``` } My `console.log()` for the month ago is `1533908066234` but for new Date is `Mon Sep 10 2018 16:34:26 GMT+0300` and with timestamp form input doesn't work. How to get correct format date of month ago for success setting into `FormControl`?
2018/09/10
[ "https://Stackoverflow.com/questions/52259142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7548062/" ]
If you Want to format a date in Angular you can use the DatePipe Try to use the pipe to format. This allows you to format a date value according to locale rules. If you need more info about this you also can check here: <https://angular.io/api/common/DatePipe> Also do this monthAgo.toLocaleDateString() I hope this helps!
I found the solution: ``` const now = new Date(); const monthAgo = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate(), now.getHours()); this.filter = new FormGroup({ start: new FormControl(monthAgo , []), end: new FormControl(now, []) }); ``` I converting the date from timestamp to string format. That's all. If somebody knows how to rewriting this more elegantly, I would be grateful.
52,259,142
I have the form for date filter and I trying set the default value for the start and end date for date inputs. ``` <form [formGroup]="filter" (ngSubmit)="applyFilter()"> <mat-form-field> <input matInput [matDatepicker]="start" formControlName="start" placeholder="Начальная дата"> <mat-datepicker-toggle matSuffix [for]="start"></mat-datepicker-toggle> <mat-datepicker #start></mat-datepicker> </mat-form-field> <mat-form-field> <input matInput [matDatepicker]="end" formControlName="end" placeholder="Конечная дата"> <mat-datepicker-toggle matSuffix [for]="end"></mat-datepicker-toggle> <mat-datepicker #end></mat-datepicker> </mat-form-field> ``` And TS part ``` refreshFilter() { const now = new Date(); const monthAgo = new Date().setMonth(now.getMonth() - 1).toString(); console.log(monthAgo) console.log(now) this.filter = new FormGroup({ start: new FormControl(monthAgo, []), end: new FormControl(now, []) }); ``` } My `console.log()` for the month ago is `1533908066234` but for new Date is `Mon Sep 10 2018 16:34:26 GMT+0300` and with timestamp form input doesn't work. How to get correct format date of month ago for success setting into `FormControl`?
2018/09/10
[ "https://Stackoverflow.com/questions/52259142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7548062/" ]
I followed the following steps and it worked as expected: * created a new Angular 6 app using CLI and added Angular Materials to project * imported FormsModule and ReactiveFormsModule in app.module.ts * copied exactly the same html markup as you provided into app.component.html * added the below code in app.component.ts ``` import { Component, OnInit } from '@angular/core'; import {FormControl, FormGroup} from '@angular/forms'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { filter: FormGroup ngOnInit() { ``` let now = new Date(); let monthAgo = new Date(); monthAgo.setMonth(now.getMonth() - 1); this.filter = new FormGroup({ start: new FormControl(monthAgo, []), end: new FormControl(now, []) }); ``` } } ``` Hope this helps.
I found the solution: ``` const now = new Date(); const monthAgo = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate(), now.getHours()); this.filter = new FormGroup({ start: new FormControl(monthAgo , []), end: new FormControl(now, []) }); ``` I converting the date from timestamp to string format. That's all. If somebody knows how to rewriting this more elegantly, I would be grateful.
450,674
> > Is it possible to find the convergent value of the series: $\sum\limits\_{x=0}^{\infty}(x+3) \cdot a^x $ where $a$ is a constant less than 1? > > > I thought about expanding: $\sum\limits\_{x=0}^{\infty}(x+3) \cdot a^x =\sum\limits\_{x=0}^{\infty}x \cdot a^x + 3 \sum\limits\_{x=0}^{\infty} a^x$ and the second term is just $\cfrac{3}{1-a}$, but I don't know what to do with the first term. Is there a general method to solve these types of problems? I that there are many types of convergent tests but not sure about methods to actually find convergent value. Thanks in advance.
2013/07/23
[ "https://math.stackexchange.com/questions/450674", "https://math.stackexchange.com", "https://math.stackexchange.com/users/73163/" ]
$$\sum\_{x=0}^{\infty} a^x = \dfrac1{1-a}$$ $$\sum\_{x=0}^{\infty} xa^x = \sum\_{x=0}^{\infty} a (xa^{x-1}) = \sum\_{x=0}^{\infty} a\dfrac{d}{da}\left(a^x\right) = a\dfrac{d}{da}\left(\sum\_{x=0}^{\infty} a^x\right) = a \dfrac{d}{da}\left(\dfrac1{1-a}\right) = \dfrac{a}{(1-a)^2}$$
Continuing your own thoughts(Hint): $$(\frac{1}{1-x})' = (\sum\_{n=0}^{\infty}x^n)' = \sum\_{n=1}^{\infty}nx^{n-1} = \sum\_{n=0}^{\infty}(n+1)x^n$$
36,275
This is roughly what my data file looks like: ``` # Monid U B V R I u g r i J Jerr H Herr K Kerr IRAC1 I1err IRAC2 I2err IRAC3 I3err IRAC4 I4err MIPS24 M24err SpT HaEW mem comp Mon-000001 99.999 99.999 21.427 99.999 18.844 99.999 99.999 99.999 99.999 16.144 99.999 15.809 0.137 16.249 99.999 15.274 0.033 15.286 0.038 99.999 99.999 99.999 99.999 99.999 99.999 null 55.000 1 N Mon-000002 99.999 99.999 20.905 19.410 17.517 99.999 99.999 99.999 99.999 15.601 0.080 15.312 0.100 14.810 0.110 14.467 0.013 14.328 0.019 14.276 0.103 99.999 0.048 99.999 99.999 null -99.999 2 N ``` ...and it's a total of 31mb in size. Here's my python script that pulls the Mon-###### IDs (found at the beginning of each of the lines). ``` import re def pullIDs(file_input): '''Pulls Mon-IDs from input file.''' arrayID = [] with open(file_input,'rU') as user_file: for line in user_file: arrayID.append(re.findall('Mon\-\d{6}',line)) return arrayID print pullIDs(raw_input("Enter your first file: ")) ``` The script works but for this particular file it ran for well into 5 minutes and I eventually just killed the process due to impatience. Is this just something I'll have to deal with in python? i.e. Should this be written with a compiled language considering the size of my data file? Further info: This script is being run within Emacs. This, by the checked answer, explains why it was running so slow.
2013/11/28
[ "https://codereview.stackexchange.com/questions/36275", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/27245/" ]
You said in comments that you don't know how to create a self-contained test case. But that's really easy! All that's needed is a function like this: ``` def test_case(filename, n): """Write n lines of test data to filename.""" with open(filename, 'w') as f: for i in range(n): f.write('Mon-{0:06d} {1}\n'.format(i + 1, ' 99.999' * 20)) ``` You can use this to make a test case of about the right size: ``` >>> test_case('cr36275.data', 200000) >>> import os >>> os.stat('cr36275.data').st_size 34400000 ``` That's about 34 MiB so close enough. Now we can see how fast your code really is, using the [`timeit`](http://docs.python.org/3/library/timeit.html) module: ``` >>> from timeit import timeit >>> timeit(lambda:pullIDs('cr36275.data'), number=1) 1.3354740142822266 ``` Just over a second. There's nothing wrong with your code or the speed of Python. So why does it take you many minutes? Well, you say that you're running it inside Emacs. That means that when you run ``` >>> pullIDs('cr36275.data') ``` Python prints out a list of 200,000 ids, and Emacs reads this line of output into the `*Python*` buffer and *applies syntax highlighting rules to it as it goes*. Emacs' syntax highlighting code is designed to work on lines of source code (at most a few hundred characters but mostly 80 characters or less), not on lines of output that are millions of characters long. This is what is taking all the time. So don't do that. Read the list of ids into a variable and if you need to look at it, use slicing to look at bits of it: ``` >>> ids = pullIDs('cr36275.data') >>> ids[:10] [['Mon-000001'], ['Mon-000002'], ['Mon-000003'], ['Mon-000004'], ['Mon-000005'], ['Mon-000006'], ['Mon-000007'], ['Mon-000008'], ['Mon-000009'], ['Mon-000010']] ```
If you know that `Mon-######` IDS will always be in the first part of each line there is no need to `.findall(..)`, just extract the first 10 characters from the line (granted the `Mon-######` is never more than 10 characters
45,450,744
I was unable set the width for an inline element `<span>` while creating a table-row with multiple span elements. I was able to modify the width once I put a `float: left` as well. Why was I not able to set the width and height of inline elements? How does adding a float change things?
2017/08/02
[ "https://Stackoverflow.com/questions/45450744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6748518/" ]
Using `@decorator` is not the only possible syntax. You can put `B = decorator(A)` after the class definition. ``` class A: ... B = decorator(A) ``` Now you still have a reference on the undecorated `A`, and you have a decorated version `B`.
I think I have worked it out. That's not really a good idea. ``` def make_variant(cls): suffix='VARIANT' new = type(cls.__name__+suffix, (cls, ), {}) # new.__repr__ = lambda self: 'HELLO' # Just do whatever needed here assert cls.__name__ + suffix not in globals() globals()[cls.__name__+suffix] = new # Think twice about this line return cls @make_variant class A: def __init__(self): pass print(AVARIANT(), A()) ```
45,450,744
I was unable set the width for an inline element `<span>` while creating a table-row with multiple span elements. I was able to modify the width once I put a `float: left` as well. Why was I not able to set the width and height of inline elements? How does adding a float change things?
2017/08/02
[ "https://Stackoverflow.com/questions/45450744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6748518/" ]
When you invoke a function using decorator syntax: ``` @my_decorator_function class A: pass ``` The decorator function's return value will replace the existing definition of `A`. So if you want it to create a new class and "return it while preserving the original A", you've got a tricky challenge. What you `return` will replace `A`, so you need to decide if that should be the original `A` or the new class. You can put the other one somewhere else. For instance, this decorator would replace `A` with a subclass, and the subclass will make the original `A` class available as a class attribute named `_orig`: ``` def class_decorator(cls): class SubClass(cls): _orig = cls # add other stuff here? return SubClass ``` You can add extra logic to copy the original class's `__name__` and `__doc__` into the new class if you want to. You could also turn the logic around, and add `SubClass` as an attribute of `cls` before returning the otherwise unmodified `cls`.
Using `@decorator` is not the only possible syntax. You can put `B = decorator(A)` after the class definition. ``` class A: ... B = decorator(A) ``` Now you still have a reference on the undecorated `A`, and you have a decorated version `B`.
45,450,744
I was unable set the width for an inline element `<span>` while creating a table-row with multiple span elements. I was able to modify the width once I put a `float: left` as well. Why was I not able to set the width and height of inline elements? How does adding a float change things?
2017/08/02
[ "https://Stackoverflow.com/questions/45450744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6748518/" ]
Using `@decorator` is not the only possible syntax. You can put `B = decorator(A)` after the class definition. ``` class A: ... B = decorator(A) ``` Now you still have a reference on the undecorated `A`, and you have a decorated version `B`.
The other answers have done a good job, but to make it crystal clear why you don't want to do this: ``` def dec(cls): new_cls = type(cls.__name__, (cls,), {}) return new_cls @dec class A(): pass ``` Now inspect the method resolution order class `A`: ``` >>> A.__mro__ (<class '__main__.A'>, <class '__main__.A'>, <class 'object'>) >>> classes = A.__mro__ >>> classes[0].__name__ 'A' >>> classes[1].__name__ 'A' ``` TWO class `A`s! Are they the same? ``` >>> classes[0] is classes[1] False ``` Nope; different. The current variable `A` is pointing to the lowest one of course: ``` >>> A is classes[0] True ``` But now you've lost name-access to the parent. That's usually not optimal. In short: you are creating a metric ton of confusion and ambiguity for yourself a few months from now when you have forgotten all about what you did. Do something else. If you really want to, here is an idea for spinning out new subclasses: ``` def add_babymaker(cls): '''Adds a method for making new child classes.''' def babymaker(name=None): '''Creates a new child class based on the parent class.''' name = name if name is not None else cls.__name__ new_cls = type(name, (cls,), {}) return new_cls cls.babymaker = babymaker return cls @add_babymaker class A(): pass B = A.babymaker('B') C = A.babymaker('C') ANew = A.babymaker() ```
45,450,744
I was unable set the width for an inline element `<span>` while creating a table-row with multiple span elements. I was able to modify the width once I put a `float: left` as well. Why was I not able to set the width and height of inline elements? How does adding a float change things?
2017/08/02
[ "https://Stackoverflow.com/questions/45450744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6748518/" ]
When you invoke a function using decorator syntax: ``` @my_decorator_function class A: pass ``` The decorator function's return value will replace the existing definition of `A`. So if you want it to create a new class and "return it while preserving the original A", you've got a tricky challenge. What you `return` will replace `A`, so you need to decide if that should be the original `A` or the new class. You can put the other one somewhere else. For instance, this decorator would replace `A` with a subclass, and the subclass will make the original `A` class available as a class attribute named `_orig`: ``` def class_decorator(cls): class SubClass(cls): _orig = cls # add other stuff here? return SubClass ``` You can add extra logic to copy the original class's `__name__` and `__doc__` into the new class if you want to. You could also turn the logic around, and add `SubClass` as an attribute of `cls` before returning the otherwise unmodified `cls`.
I think I have worked it out. That's not really a good idea. ``` def make_variant(cls): suffix='VARIANT' new = type(cls.__name__+suffix, (cls, ), {}) # new.__repr__ = lambda self: 'HELLO' # Just do whatever needed here assert cls.__name__ + suffix not in globals() globals()[cls.__name__+suffix] = new # Think twice about this line return cls @make_variant class A: def __init__(self): pass print(AVARIANT(), A()) ```
45,450,744
I was unable set the width for an inline element `<span>` while creating a table-row with multiple span elements. I was able to modify the width once I put a `float: left` as well. Why was I not able to set the width and height of inline elements? How does adding a float change things?
2017/08/02
[ "https://Stackoverflow.com/questions/45450744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6748518/" ]
The other answers have done a good job, but to make it crystal clear why you don't want to do this: ``` def dec(cls): new_cls = type(cls.__name__, (cls,), {}) return new_cls @dec class A(): pass ``` Now inspect the method resolution order class `A`: ``` >>> A.__mro__ (<class '__main__.A'>, <class '__main__.A'>, <class 'object'>) >>> classes = A.__mro__ >>> classes[0].__name__ 'A' >>> classes[1].__name__ 'A' ``` TWO class `A`s! Are they the same? ``` >>> classes[0] is classes[1] False ``` Nope; different. The current variable `A` is pointing to the lowest one of course: ``` >>> A is classes[0] True ``` But now you've lost name-access to the parent. That's usually not optimal. In short: you are creating a metric ton of confusion and ambiguity for yourself a few months from now when you have forgotten all about what you did. Do something else. If you really want to, here is an idea for spinning out new subclasses: ``` def add_babymaker(cls): '''Adds a method for making new child classes.''' def babymaker(name=None): '''Creates a new child class based on the parent class.''' name = name if name is not None else cls.__name__ new_cls = type(name, (cls,), {}) return new_cls cls.babymaker = babymaker return cls @add_babymaker class A(): pass B = A.babymaker('B') C = A.babymaker('C') ANew = A.babymaker() ```
I think I have worked it out. That's not really a good idea. ``` def make_variant(cls): suffix='VARIANT' new = type(cls.__name__+suffix, (cls, ), {}) # new.__repr__ = lambda self: 'HELLO' # Just do whatever needed here assert cls.__name__ + suffix not in globals() globals()[cls.__name__+suffix] = new # Think twice about this line return cls @make_variant class A: def __init__(self): pass print(AVARIANT(), A()) ```
45,450,744
I was unable set the width for an inline element `<span>` while creating a table-row with multiple span elements. I was able to modify the width once I put a `float: left` as well. Why was I not able to set the width and height of inline elements? How does adding a float change things?
2017/08/02
[ "https://Stackoverflow.com/questions/45450744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6748518/" ]
When you invoke a function using decorator syntax: ``` @my_decorator_function class A: pass ``` The decorator function's return value will replace the existing definition of `A`. So if you want it to create a new class and "return it while preserving the original A", you've got a tricky challenge. What you `return` will replace `A`, so you need to decide if that should be the original `A` or the new class. You can put the other one somewhere else. For instance, this decorator would replace `A` with a subclass, and the subclass will make the original `A` class available as a class attribute named `_orig`: ``` def class_decorator(cls): class SubClass(cls): _orig = cls # add other stuff here? return SubClass ``` You can add extra logic to copy the original class's `__name__` and `__doc__` into the new class if you want to. You could also turn the logic around, and add `SubClass` as an attribute of `cls` before returning the otherwise unmodified `cls`.
The other answers have done a good job, but to make it crystal clear why you don't want to do this: ``` def dec(cls): new_cls = type(cls.__name__, (cls,), {}) return new_cls @dec class A(): pass ``` Now inspect the method resolution order class `A`: ``` >>> A.__mro__ (<class '__main__.A'>, <class '__main__.A'>, <class 'object'>) >>> classes = A.__mro__ >>> classes[0].__name__ 'A' >>> classes[1].__name__ 'A' ``` TWO class `A`s! Are they the same? ``` >>> classes[0] is classes[1] False ``` Nope; different. The current variable `A` is pointing to the lowest one of course: ``` >>> A is classes[0] True ``` But now you've lost name-access to the parent. That's usually not optimal. In short: you are creating a metric ton of confusion and ambiguity for yourself a few months from now when you have forgotten all about what you did. Do something else. If you really want to, here is an idea for spinning out new subclasses: ``` def add_babymaker(cls): '''Adds a method for making new child classes.''' def babymaker(name=None): '''Creates a new child class based on the parent class.''' name = name if name is not None else cls.__name__ new_cls = type(name, (cls,), {}) return new_cls cls.babymaker = babymaker return cls @add_babymaker class A(): pass B = A.babymaker('B') C = A.babymaker('C') ANew = A.babymaker() ```
30,759,860
What is the Correct Way to retrieve a column value based on certain select filter on a Model variable availed by `compact` method inside the blade. (Larevl 5) I read that Its a bad practice to query database staright from views, and hence i followed the convention to avail the required data with `compact` method to view However, In a scenario where I need to query another table based on certain column value returned in foreach loop inside a blade from first table, I am unable to figure out correct Approach Example: I have two Models `User` & `Group` Schema `User` Table ``` id,name,email,group_id ``` Scheme Group Table `id`,`groupname` Here is the UserController -> compact method ``` $users = \App\User::all(array('id','name','email','group_id')); $groups = \App\Group::all(array('id','group_name')); return view('user.index', compact('users','groups')); ``` Here how the blade needs them ``` @foreach ($users as $user) <tr> <th>{{$user->id}}</th> <th>{{$user->name}}</th> <th>{{$user->email}}</th> <th> <!-- Here i need to run something like select group_name from group where id = $user->id --> {{$groups->where('id','=',$user->group_id) }} </th> <th>Actions</th> </tr> @endforeach ``` I know this returns an array , and I'have two questions here 1. How to get the value for `group_name` column from the Group Model based on group.`id` = `$user->id` in a foreach loop 2. Since Its a bad practice to query db from blade, how would I avail the values from a model by passing data via compact from controller to blade, when the where clause parameter's are not yet known. **Edit 1:** I modified the last group query as ``` <th>@if($groups->where('id','=',$user->group_id)) @foreach($groups as $group) {{$group->group_name}} @endforeach @endif </th> ``` And I was able to get the result, however this again isn't a correct approach , so question remain unanswered
2015/06/10
[ "https://Stackoverflow.com/questions/30759860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1679510/" ]
You can change your ui-select to: ``` <ui-select ng-model="fm.countryCode" id="countryCode"> <ui-select-match placeholder="Select a country...">{{$select.selected.label}}</ui-select-match> <ui-select-choices repeat="item.value as item in countries | filter: $select.search" value="{{$select.selected.value}}"> <div ng-bind-html="item.label | highlight: $select.search"></div> <small ng-bind-html="item.value | highlight: $select.search"></small> </ui-select-choices> </ui-select> ``` This will take item.value as the complete item, instead of both value and label. So the repeat part: `<ui-select-choices repeat="item.value as item in countries` does the trick.
Just change ``` fm.countryCode = {{fm.countryCode}} ``` for ``` fm.countryCode = {{fm.countryCode.value}} ```
30,759,860
What is the Correct Way to retrieve a column value based on certain select filter on a Model variable availed by `compact` method inside the blade. (Larevl 5) I read that Its a bad practice to query database staright from views, and hence i followed the convention to avail the required data with `compact` method to view However, In a scenario where I need to query another table based on certain column value returned in foreach loop inside a blade from first table, I am unable to figure out correct Approach Example: I have two Models `User` & `Group` Schema `User` Table ``` id,name,email,group_id ``` Scheme Group Table `id`,`groupname` Here is the UserController -> compact method ``` $users = \App\User::all(array('id','name','email','group_id')); $groups = \App\Group::all(array('id','group_name')); return view('user.index', compact('users','groups')); ``` Here how the blade needs them ``` @foreach ($users as $user) <tr> <th>{{$user->id}}</th> <th>{{$user->name}}</th> <th>{{$user->email}}</th> <th> <!-- Here i need to run something like select group_name from group where id = $user->id --> {{$groups->where('id','=',$user->group_id) }} </th> <th>Actions</th> </tr> @endforeach ``` I know this returns an array , and I'have two questions here 1. How to get the value for `group_name` column from the Group Model based on group.`id` = `$user->id` in a foreach loop 2. Since Its a bad practice to query db from blade, how would I avail the values from a model by passing data via compact from controller to blade, when the where clause parameter's are not yet known. **Edit 1:** I modified the last group query as ``` <th>@if($groups->where('id','=',$user->group_id)) @foreach($groups as $group) {{$group->group_name}} @endforeach @endif </th> ``` And I was able to get the result, however this again isn't a correct approach , so question remain unanswered
2015/06/10
[ "https://Stackoverflow.com/questions/30759860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1679510/" ]
You can change your ui-select to: ``` <ui-select ng-model="fm.countryCode" id="countryCode"> <ui-select-match placeholder="Select a country...">{{$select.selected.label}}</ui-select-match> <ui-select-choices repeat="item.value as item in countries | filter: $select.search" value="{{$select.selected.value}}"> <div ng-bind-html="item.label | highlight: $select.search"></div> <small ng-bind-html="item.value | highlight: $select.search"></small> </ui-select-choices> </ui-select> ``` This will take item.value as the complete item, instead of both value and label. So the repeat part: `<ui-select-choices repeat="item.value as item in countries` does the trick.
Ok replace ``` fm.countryCode = {{fm.countryCode}} ``` to ``` fm.countryCode = {{fm.countryCode.value}} ``` See in plunker <http://plnkr.co/edit/EoBl4YZ6QfnJdHfOMM10?p=preview>
30,759,860
What is the Correct Way to retrieve a column value based on certain select filter on a Model variable availed by `compact` method inside the blade. (Larevl 5) I read that Its a bad practice to query database staright from views, and hence i followed the convention to avail the required data with `compact` method to view However, In a scenario where I need to query another table based on certain column value returned in foreach loop inside a blade from first table, I am unable to figure out correct Approach Example: I have two Models `User` & `Group` Schema `User` Table ``` id,name,email,group_id ``` Scheme Group Table `id`,`groupname` Here is the UserController -> compact method ``` $users = \App\User::all(array('id','name','email','group_id')); $groups = \App\Group::all(array('id','group_name')); return view('user.index', compact('users','groups')); ``` Here how the blade needs them ``` @foreach ($users as $user) <tr> <th>{{$user->id}}</th> <th>{{$user->name}}</th> <th>{{$user->email}}</th> <th> <!-- Here i need to run something like select group_name from group where id = $user->id --> {{$groups->where('id','=',$user->group_id) }} </th> <th>Actions</th> </tr> @endforeach ``` I know this returns an array , and I'have two questions here 1. How to get the value for `group_name` column from the Group Model based on group.`id` = `$user->id` in a foreach loop 2. Since Its a bad practice to query db from blade, how would I avail the values from a model by passing data via compact from controller to blade, when the where clause parameter's are not yet known. **Edit 1:** I modified the last group query as ``` <th>@if($groups->where('id','=',$user->group_id)) @foreach($groups as $group) {{$group->group_name}} @endforeach @endif </th> ``` And I was able to get the result, however this again isn't a correct approach , so question remain unanswered
2015/06/10
[ "https://Stackoverflow.com/questions/30759860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1679510/" ]
You can change your ui-select to: ``` <ui-select ng-model="fm.countryCode" id="countryCode"> <ui-select-match placeholder="Select a country...">{{$select.selected.label}}</ui-select-match> <ui-select-choices repeat="item.value as item in countries | filter: $select.search" value="{{$select.selected.value}}"> <div ng-bind-html="item.label | highlight: $select.search"></div> <small ng-bind-html="item.value | highlight: $select.search"></small> </ui-select-choices> </ui-select> ``` This will take item.value as the complete item, instead of both value and label. So the repeat part: `<ui-select-choices repeat="item.value as item in countries` does the trick.
A more elegant solution IMO would be: changing this: ``` <ui-select ng-model="fm.countryCode" id="countryCode"> <ui-select-match placeholder="Select a country...">{{$select.selected.label}}</ui-select-match> <ui-select-choices repeat="item in countries | filter: $select.search" value="{{$select.selected.value}}"> <div ng-bind-html="item.label | highlight: $select.search"></div> <small ng-bind-html="item.value | highlight: $select.search"></small> </ui-select-choices> </ui-select> ``` to this: ``` <select ng-options="country.value as country.label for country in countries" ng-model="fm.countryCode"> </select> ``` [plunkr](http://plnkr.co/edit/JrgnTH?p=preview)
27,788,728
This question could be all around but I have tried most answers and permission 777. But, still no luck. **/etc/apache2/sites-available/mysite.conf** ``` <VirtualHost *:80> ServerName www.mysite.com ServerAdmin mymail@mail.com DocumentRoot /var/www/html/wordpress ErrorLog ${APACHE_LOG_DIR}/mysite_error.log CustomLog ${APACHE_LOG_DIR}/mysite.log combined </VirtualHost> ``` **/etc/vsftpd.conf** ``` listen=YES anonymous_enable=NO local_enable=YES write_enable=YES dirmessage_enable=YES use_localtime=YES xferlog_enable=YES connect_from_port_20=YES chroot_local_user=YES secure_chroot_dir=/var/run/vsftpd/empty pam_service_name=vsftpd rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key allow_writeable_chroot=YES ``` I set permission `777` to `/usr/share/wordpress` and `/var/lib/wordpress`.
2015/01/05
[ "https://Stackoverflow.com/questions/27788728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619540/" ]
The update creates a directory in wp-content/update inside the site directory. Linux does not set permissions automatically of child directories to those of the parent. Therefore wp-content/upload will not necessarily have 777 permissions. Try change permissions of wp-content/update to 777. If this works it means that the owner of the WordPress folders is not the the user trying to update the site. What worked for me was to add my ftp client to the group that the owner of the WordPress process. ([How do I know which linux user Wordpress uses for plugin installation](https://stackoverflow.com/questions/13186546/how-do-i-know-which-linux-user-wordpress-uses-for-plugin-installation)) to find the owner. and then set all directories to 775 permissions and files to 665 in the site directory. ``` chmod 775 $(find -type d) chmod 665 $(find -type f) ```
You need to give write permissions to the relevant directories. Ideally, you should do it only for the relevant file or folder **and then revert the permissions back so as to not leave your site vulnerable**. You can fix this using the following commands from the command line (assuming that you are in the WordPress root folder): ``` # cd wp-content # chmod -R a+w plugins # chmod -R a+w themes # chmod -R a+w upgrade ``` The safest solution is to add Apache to the same group as the owner of the WordPress installation and change all group permissions to writeable. A more detailed solution can be found at: <http://techzog.com/wordpress/fixing-unpacking-package-could-not-create-directory-error-wordpress/>
4,091,267
I know that using Euler's Formula we can write cosine like the first expression, but concerning the second expression, is it correct like that? $$\cos(\theta)=\frac{e^{i\theta}+e^{-i\theta}}2$$ $$\cos(2\theta)=\frac{2e^{i\theta}+2e^{-i\theta}}2$$
2021/04/06
[ "https://math.stackexchange.com/questions/4091267", "https://math.stackexchange.com", "https://math.stackexchange.com/users/716152/" ]
No, this is not correct. You have to substitute $2\theta$ for $\theta$ which means that $$ \cos(2\theta) = \frac{e^{2i\theta} + e^{-2i\theta}}{2}. $$
No, it is not correct. Since$$\cos\theta=\frac{e^{i\theta}+e^{-i\theta}}2,$$you have$$\cos(2\theta)=\frac{e^{2i\theta}+e^{-2i\theta}}2.$$
4,091,267
I know that using Euler's Formula we can write cosine like the first expression, but concerning the second expression, is it correct like that? $$\cos(\theta)=\frac{e^{i\theta}+e^{-i\theta}}2$$ $$\cos(2\theta)=\frac{2e^{i\theta}+2e^{-i\theta}}2$$
2021/04/06
[ "https://math.stackexchange.com/questions/4091267", "https://math.stackexchange.com", "https://math.stackexchange.com/users/716152/" ]
No, this is not correct. You have to substitute $2\theta$ for $\theta$ which means that $$ \cos(2\theta) = \frac{e^{2i\theta} + e^{-2i\theta}}{2}. $$
Expression 1 $\to \cos 0=1$, Expression 2 $\to \cos 0=2>1$. Can the second expression be correct?
739,443
At my workplace we make many versions of a 5-7 page document that is basically one long table in Word 2010. The repeating header row lists the type of information in each column. The problem is that it takes forever to do the section titles manually. My team members have to insert a new row for the Section title. Manually merge the cells into one big title cell, then manually change the side borders to white. Then if the section flows onto the next page, they have to create a new row named Section Title (Continued). The result of this is very visually ugly and hard to read, with the running header row appearing to float disconnected over the first section title on each page instead of sitting beneath the title as you would see in a normal table. But the worst part is that when the document is updated and the pagination changes, someone has to go back and redo all the section titles by manually adding and deleting rows. I feel like way too many hours have been wasted on this process and there must be a way to automate some or all of it. I am also open to using a different software than Word, if it is cheap or free for commercial use. Any suggestions are appreciated.
2014/04/09
[ "https://superuser.com/questions/739443", "https://superuser.com", "https://superuser.com/users/314134/" ]
I don't think there is going to be an easy way to achieve this layout, but I hope someone will think of a simpler approach… I can think of two main approaches that you could take. I am assuming for the moment that there are no other headers/footers in the document. I have posted a document showing how **Approach two** would work at <https://www.dropbox.com/s/ngrhc8yds0umnoj/template_lorumipsum_mod1.docx> It would probably be better to look at that an see if it is even close to what you need before reading any further. **Approach one** would I think require some VBA macros to make it work. What you would do is * Remove the repeating header row * Put that row as a single-row table in the document Header, which would then repeat * Use one table for each section, with the header row in each section repeated. In that case, the main table column headings would always be above the "section headings", there would be no "cont." texts (although you may be able to fix that using a kludge), and you would have to deal with the fact that the column headings are separate from the data. That means two things: * there will be a vertical gap between the headings and the data (you can probably reduce that by ensuring that the headings row is taller than the document header) * the column widths may vary from table to table, screwing up the horizintal alignment. The only way I think you would be able to fix that easily would be to run a (VBA) macro that applied the same column widths to every row in every table. If your users aren't allowed to use VBA macros and/or the table layout can be more complex than your sample document suggests (e.g. you sometime merge/split columns) then that's probably not going to be a practical approach. **Approach two** would be to keep the table layout you have, but use some Word field codes to insert a heading on each page. I don't think the suggestion I made earlier to use { STYLEREF } fields is going to work, because they do not really provide continuation headers (for example, a STYLEREF field will typically display the text of the first header on the page, not the text of the header that is being continued). The only way I know how to do this is to use some unusual SEQ fields to keep track of the section headers and to decide what should be displayed in each page header. To make this work, your users will have to be able to work with field codes (unfortunately, they look complicated and are rather easy to break). Also, Word works quite hard to keep its headers and footers up to date, and can sometimes get a bit confused when there are lots of fields with page-dependent values in those areas. So this tends not to work so well when a document gets larger - I'd check and see whether it works for your document type and size. The specific approach I describe here makes some assumptions about what you want at the top of each page: * nothing at the top of the first page * nothing at the top of the page if the first row on the page is a section heading * otherwise, a continuation text from the previous page. The document I posted has samples of the fields you need. For each section heading the user would need to insert two table rows containing a number of fields. That is completely impractical unless the user has a mechanism that allows them to do that easily. For example, if they set up the two rows as an formatted autocorrect entry called “seched”, then all they need do is type seched followed by a space at the beginning of a table row, and the two rows would be included. There are other possibilities. What I envisage is that your starting Word document would have (at least) the first (heading) row of the table, and the first section header, i.e. “Front Pages” in your sample document. a two-row block at the beginning of each subsequent section header. Ideally, the user would be able to insert the entire block, fields and all, using an autocorrect or perhaps a building block. They would then need to modify the text in the fields. If something like that is not feasible in your environment, this approach isn’t going to be practical either. *The key concepts* for using fields in this situation are as follows: a. a field has a code and a result b. some samples of field codes are: ``` { SEQ S \c } { PAGE } { SET T “some text” } { REF T } ``` c. The { } are special field code brace pairs that you can insert on Windows versions of Word using ctrl-F9. You can’t just type them usin gthe ordinary { and } characters on the keyboard d. You can toggle between “field codes” and “field results” view using Alt-F9 The results of the above four fields might be something like ``` 4 2 (a SET field does not show a result. it just sets the value of a bookmark, in this case the bookmark “T”) some text ``` e. Many field types do not update themselves. To see the correct results, you have to select them and press F9. Often, the simplest way to do this is to select the whole document using ctrl-A, then press F9. (going into Print Preview and out again is often suggested as an option, but in fact it does not update all field types). You may need to do this when, for example, your document’s pagination has changed. For this document type, what the user should really do is * show field results rather than codes * with the insertion point in the body of the document, use ctrl-A, then F9 f. You can nest field codes in certain ways, for example the result of { IF { SEQ S \c } = 0 "S is zero' "S is not zero" } should be “S is zero” when the current value of the SEQuence variable S is 0 and you have just updated all the fields. In this case, both pairs of { } need to be the “special field code braces” g. In a document header or footer, the values of fields are generally equal to the value of the field as it would be if it were placed at the **end** of the body text in the page, not at the **beginning** of the page. SO we have to find a way to decide what a value is at the **beginning** of the page. *The method I propose* uses the following fields: In the first cell of the table heading, there are two fields: `{ SET T1 "" }` (sets the bookmark T1 to an empty string) `{ SEQ S \r1 \h }` (sets the sequence variable S to 1, hides the result) Each section heading has the following fields, except that you replace the text in the { SET T } field by the heading text for that heading ``` { SEQ S \h }{ SET T "Front pages" }{ T }{ SET "T{ SEQ S \c }" "...(cont.): { T }" }{ SEQ "P{ PAGE \#0 }N{ SEQ "P{ PAGE \#0 }" }" \r1 \h } ``` `{ SEQ S \h }` increases the value of S by 1 (in section 1, S will be 2) and the `\h` hides the result `{ SET T "Front pages" }` sets bookmark T to “Front pages”. `{ T }` (an abbreviation for `{ REF T }` displays the value of bookmark T `{ SET "T{ SEQ S \c }" … }` . In section 1, this will set the value of T2. In Section 2, it will set the value of T3, and so on. We set T2, T3 etc. to the text we want for the continuation notice in the page header. So you can either re-use the value of `{ T }` and prepend "... (cont.): " to it, as I have done above, or you can write a completely different continuation text for each section. Again, that might require the user to modify the row height so they can see all the text in all the fields. `{ SEQ S \c }` is the current value of sequence variable S. `{ SEQ "P{ PAGE \#0 }N{ SEQ "P{ PAGE \#0 }" \r1 \h }` sets the value of a sequence variable that is named according to the page number it is on and the number of such fields there are on the page. (This assumes that you are using straightforward numbering (1,2,3,4,5,etc.) you are not using chapter-page numbering (A-1,A-2 etc.) if you have more than one Word section in the document, the numbering is continuous, e.g. does not start again at 1 for each section. If you are using A,B,C etc. rather than 1,2,3 the `\#` switch should return 1,2,3. But with chapter-page numbering, this would only work if the page number was unique, e.g. A-1,A-2,B-3,B-4 etc. rather than A-1, A-2, B-1, B-2 etc. ) So for example, on page 2, the first field set up in this way will set the value of the sequence variable S2N1. The second will set the value of S2N2. I refer to this series of sequence variables as “marker variables” Above every heading row except the first, we also need a one-cell row which we will make as thin as possible (vertically) and which contains the following field codes: ``` { SEQ "P{ PAGE \#0 }N{ SEQ "P{ PAGE \#0 }" }" \r{ SEQ S \c } \h } ``` this sets the marker variable to the section number variable S. Finally, in the header (it can be all the headers or you can use a different first page header), you put ``` { IF { SEQ "P{ PAGE \#0 }N1" \c } = 0 "{ "T{ SEQ S \c }" }" "{ "T{ SEQ "P{ PAGE }N1" \c }" }" } ``` What this says is ``` If the first marker on the page has value 0 Then display the continuation text for the section that is current at the end of the page Else display the continuation text for the section number stored in the first marker on the page End If ``` When we set a marker, we always set its value either to 1 or the current section number. So the marker value will only ever be 0 on a page which has no markers, in which case the section current at the end of the page is the same as the section current at the beginning of the page. If the first marker on the page is set to 1, it is a start-of-section marker and there is no earlier end-of-section marker on the page. That means we have a section heading at the top of the page, so we display T1, i.e. a blank text. Otherwise, the first marker on the page is an end-of-section marker and that means that we need to display the continuation text for the section recorded in the marker. There is one possibility that I have not investigated in this case, and that is that the thin row containing the end-of-section marker is the first row on a page. I am not sure whether that can be avoided and it may not be easy to detect that situation, either. I think if it occurs, the only solution will be to reduce the height of the previous cell until the blank cell moves up a page.
`Repeat as header row at the top of each page` should work for you. When you have created table, click `Table properties` choose `Row` and then select option `Repeat as header row at the top of each page`. ![enter image description here](https://i.stack.imgur.com/yaCgZ.jpg)
17,411,137
The opening page of my website is picture and when clicked i want it to fade out then go to the main page. Should i fade out the picture then fade in the body of the next page or is there a way to do it all in one? ``` <script> $(document).click(function(){ $('#beach').fadeTo(3000,0.30, function() { $("#beach").attr("src",$("#link").attr("href")); }).fadeTo(500,1); return false; }); </script> <a href="welcomepage.html#link"><img id="beach" src="wedfronttest.jpg" ``` thanks in advance
2013/07/01
[ "https://Stackoverflow.com/questions/17411137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2540057/" ]
To be fair, using the "userAgent" string is not a good way to do this. It's better to check if the browser supports features and then implement (or don't implement) the specific pieces of functionality of your site that the browsers will support. Some sites that could help you out are <http://diveintohtml5.info/detect.html> and <http://modernizr.com/>
Check for the `.ie9` class that gets added to your `<html>` element. *Edited to use `hasClass` instead of `length`* ``` if ($("html").hasClass("ie9")) { } ```
17,411,137
The opening page of my website is picture and when clicked i want it to fade out then go to the main page. Should i fade out the picture then fade in the body of the next page or is there a way to do it all in one? ``` <script> $(document).click(function(){ $('#beach').fadeTo(3000,0.30, function() { $("#beach").attr("src",$("#link").attr("href")); }).fadeTo(500,1); return false; }); </script> <a href="welcomepage.html#link"><img id="beach" src="wedfronttest.jpg" ``` thanks in advance
2013/07/01
[ "https://Stackoverflow.com/questions/17411137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2540057/" ]
To be fair, using the "userAgent" string is not a good way to do this. It's better to check if the browser supports features and then implement (or don't implement) the specific pieces of functionality of your site that the browsers will support. Some sites that could help you out are <http://diveintohtml5.info/detect.html> and <http://modernizr.com/>
To detect MSIE (v6 - v7 - v8 - v9 - v10 - v11) easily ``` if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) { // MSIE } ```
17,411,137
The opening page of my website is picture and when clicked i want it to fade out then go to the main page. Should i fade out the picture then fade in the body of the next page or is there a way to do it all in one? ``` <script> $(document).click(function(){ $('#beach').fadeTo(3000,0.30, function() { $("#beach").attr("src",$("#link").attr("href")); }).fadeTo(500,1); return false; }); </script> <a href="welcomepage.html#link"><img id="beach" src="wedfronttest.jpg" ``` thanks in advance
2013/07/01
[ "https://Stackoverflow.com/questions/17411137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2540057/" ]
To be fair, using the "userAgent" string is not a good way to do this. It's better to check if the browser supports features and then implement (or don't implement) the specific pieces of functionality of your site that the browsers will support. Some sites that could help you out are <http://diveintohtml5.info/detect.html> and <http://modernizr.com/>
``` function runvlc(){ if (navigator.userAgent.toLowerCase().indexOf("msie")!==-1|| (navigator.appVersion.indexOf('Trident/') > 0)){ alert('iexplorer') } else if (navigator.userAgent.toLowerCase().indexOf("msie")==-1){ alert('others') } }; ``` This one works.
73,846
Consider the following setting: * A production DB * A dev db, on which schema changes are made to enable new features When the development of a new feature is complete, I have to manually update the prod db schema until `pg_dump --schema-only` on both DBs is identical. This process is error prone and tedious. So, I am looking for a tool that can: * Show a summary of the differences between two schemas (like `diff`). Note that I am not looking for a mere textual diff of the schema, but a more elaborate tool that can draw conclusions like "Table `X` has a new column `Y`". * Auto-generate the SQL code that would convert one schema to another (like [`patch`](https://en.wikipedia.org/wiki/Patch_(Unix))) **Is there a schema [diff](https://en.wikipedia.org/wiki/Diff)/[patch](https://en.wikipedia.org/wiki/Patch_(Unix)) tool that can help me convert prod schemas to the more advanced dev schemas?**
2014/08/13
[ "https://dba.stackexchange.com/questions/73846", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/972/" ]
*Sorry to resurrect an old question* Recently I have been using the ~~[0xDBE](https://www.jetbrains.com/dbe/)~~ [DataGrip](https://www.jetbrains.com/datagrip/) Database management tool by JetBrains. It supports multiple database engines, in the excellent Jetbrains IDE, and a key feature I have found useful is the ability to `diff` 2 tables (DEV and PROD). Below is a screenshot of the diff in action (in this case there is only one column difference). The screenshot is the result of the "Merge Right" button at the top, generating the SQL required to bring the right table up to scratch. ![0xDBE SQL Table Diff](https://i.stack.imgur.com/VxaNv.png) Hope this new tool helps.
Use [liquibase](http://www.liquibase.org/quickstart.html). It supports [diff](http://www.liquibase.org/documentation/diff.html), generating a db from scratch, patching a db, rolling back a db, and a bunch of other stuff. You used to have to write everything in XML with liquibase, but not anymore. You can write 99% of it in the SQL dialect of your choosing. Example: ``` --liquibase formatted sql --changeset neil:1 create table contacts( contact_id serial primary key, name text not null unique ); --changeset neil:2 alter table contacts add column phone_num text; ``` You should keep your liquibase changelogs in git or what-have-you.
16,899,601
I am building a student database for a high school. I have been able to solve most of my problems with the exception of one. The tables I currently have are for records of the current school term. I am trying to find a way to permanently keep records for the first term, second term, third term and even after the student graduates. Student information will still be stored in the database permanently. Please can anyone give me an idea of how I should build it?
2013/06/03
[ "https://Stackoverflow.com/questions/16899601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2418765/" ]
Add a field "Term", where you write the term, which this record is for.
I think the most logical way is to have **Year** (calendar year) and **Term** (semester term: Spring, Summer, Fall) fields associated to each student. This way you could fully distinguish attendance by either calendar year or term. For graduation status you could add either graduation flag or graduation date, or both. **ADDED:** In response to comment below. Yes, I think it does make more sense to track prospective students and enrolled academic students separately. You either can track those in a stand along table or implement additional fields to the existing table. As an example, you could have a field **person\_status** as *enrolled*, *graduated*, *prospective*. Your ultimate structure really depends on what level of detail you try to achieve.
19,834
I've been doing some research into 3D mice. Pretty much the only game in town is the space mouse from 3Dconnexion. In doing this I discovered that its original designer John Hilton left after the acquisition and went on to form a company called Spatial Freedom which produced a rival controller called "Astroid". See <https://www.digitalengineering247.com/article/whats-not-to-like-about-astroid> Pretty much all evidence of this company and product seems to have been eliminated from the internet. Does anyone know what happened? I can think of three possibilities: 1. the company was bought out 2. 3Dconnexion sued over the similarity and they were forced to fold 3. The company folded due to being unable to carve out a niche of its own Evidence * spatialfreedom.com site is parked Implication: the company folded * no videos from Spatial Freedom or about Astroid on YouTube Guess: they were pulled by YouTube at the request of 3Dconnexion’s lawyers I've recently discovered an attempt to create an open hardware version <https://github.com/mattogodoy/mighty-mouse> which I like the look of. If the answer to this question is 2 that project would be under threat. However according to <https://spacemice.org/pdf/Astroid_Whitepaper.pdf>, the Astroid was based on a new design for which a new patent was at least sought. A search shows 3Dconnexion own some patents which cover their products e.g <https://patents.justia.com/assignee/3dconnexion-gmbh>. They seem dubiously broad to my "open source" mindset but money and lawyers...
2021/05/13
[ "https://retrocomputing.stackexchange.com/questions/19834", "https://retrocomputing.stackexchange.com", "https://retrocomputing.stackexchange.com/users/11079/" ]
Here's a contemporary (ca. 2013) [White Paper](https://web.archive.org/web/20130730044911/http://www.spatialfreedom.com/downloads/Astroid%20White%20Paper.pdf) produced by the company. There was one US patent granted, which (US7706916B2) has "Status Expired - Fee Related" and another which (US20080252661A1) was abandoned. The inventor has other patents in his name, some unrelated to 3D mice and some assigned to Spaceball Technologies Inc. By far and away the easiest way to find out the history would be to contact the erstwhile principal of Spatial Freedom and *ask*. His association with the corporation seems to have ended in 2014 one way or another. His Linkedin profile is here: [![enter image description here](https://i.stack.imgur.com/9sBrj.png)](https://i.stack.imgur.com/9sBrj.png)
No it has not folded, been sued or bought out and it's still an active company, see <https://abr.business.gov.au/ABN/View/32100627370>. Though I don't think it's making Astroid 6000 anymore. There are no videos online because Spatial Freedom was founded well before online videos were a standard thing. So trying to find context like that isn't going to happen.
19,834
I've been doing some research into 3D mice. Pretty much the only game in town is the space mouse from 3Dconnexion. In doing this I discovered that its original designer John Hilton left after the acquisition and went on to form a company called Spatial Freedom which produced a rival controller called "Astroid". See <https://www.digitalengineering247.com/article/whats-not-to-like-about-astroid> Pretty much all evidence of this company and product seems to have been eliminated from the internet. Does anyone know what happened? I can think of three possibilities: 1. the company was bought out 2. 3Dconnexion sued over the similarity and they were forced to fold 3. The company folded due to being unable to carve out a niche of its own Evidence * spatialfreedom.com site is parked Implication: the company folded * no videos from Spatial Freedom or about Astroid on YouTube Guess: they were pulled by YouTube at the request of 3Dconnexion’s lawyers I've recently discovered an attempt to create an open hardware version <https://github.com/mattogodoy/mighty-mouse> which I like the look of. If the answer to this question is 2 that project would be under threat. However according to <https://spacemice.org/pdf/Astroid_Whitepaper.pdf>, the Astroid was based on a new design for which a new patent was at least sought. A search shows 3Dconnexion own some patents which cover their products e.g <https://patents.justia.com/assignee/3dconnexion-gmbh>. They seem dubiously broad to my "open source" mindset but money and lawyers...
2021/05/13
[ "https://retrocomputing.stackexchange.com/questions/19834", "https://retrocomputing.stackexchange.com", "https://retrocomputing.stackexchange.com/users/11079/" ]
Here's a contemporary (ca. 2013) [White Paper](https://web.archive.org/web/20130730044911/http://www.spatialfreedom.com/downloads/Astroid%20White%20Paper.pdf) produced by the company. There was one US patent granted, which (US7706916B2) has "Status Expired - Fee Related" and another which (US20080252661A1) was abandoned. The inventor has other patents in his name, some unrelated to 3D mice and some assigned to Spaceball Technologies Inc. By far and away the easiest way to find out the history would be to contact the erstwhile principal of Spatial Freedom and *ask*. His association with the corporation seems to have ended in 2014 one way or another. His Linkedin profile is here: [![enter image description here](https://i.stack.imgur.com/9sBrj.png)](https://i.stack.imgur.com/9sBrj.png)
Its a pity the Astroid 6000 is no longer available, we still use a couple of them in our design office currently with Inventor 2019, these were purchased in 2008 and still work perfectly. Drivers were still available via spatialfreedom website, although couldnt access it today? These were also quarter of the price of the 3D Connexion items and cant knock the quality as these have been used eight hours a day for 13 years with no issues at all.
19,834
I've been doing some research into 3D mice. Pretty much the only game in town is the space mouse from 3Dconnexion. In doing this I discovered that its original designer John Hilton left after the acquisition and went on to form a company called Spatial Freedom which produced a rival controller called "Astroid". See <https://www.digitalengineering247.com/article/whats-not-to-like-about-astroid> Pretty much all evidence of this company and product seems to have been eliminated from the internet. Does anyone know what happened? I can think of three possibilities: 1. the company was bought out 2. 3Dconnexion sued over the similarity and they were forced to fold 3. The company folded due to being unable to carve out a niche of its own Evidence * spatialfreedom.com site is parked Implication: the company folded * no videos from Spatial Freedom or about Astroid on YouTube Guess: they were pulled by YouTube at the request of 3Dconnexion’s lawyers I've recently discovered an attempt to create an open hardware version <https://github.com/mattogodoy/mighty-mouse> which I like the look of. If the answer to this question is 2 that project would be under threat. However according to <https://spacemice.org/pdf/Astroid_Whitepaper.pdf>, the Astroid was based on a new design for which a new patent was at least sought. A search shows 3Dconnexion own some patents which cover their products e.g <https://patents.justia.com/assignee/3dconnexion-gmbh>. They seem dubiously broad to my "open source" mindset but money and lawyers...
2021/05/13
[ "https://retrocomputing.stackexchange.com/questions/19834", "https://retrocomputing.stackexchange.com", "https://retrocomputing.stackexchange.com/users/11079/" ]
No it has not folded, been sued or bought out and it's still an active company, see <https://abr.business.gov.au/ABN/View/32100627370>. Though I don't think it's making Astroid 6000 anymore. There are no videos online because Spatial Freedom was founded well before online videos were a standard thing. So trying to find context like that isn't going to happen.
Its a pity the Astroid 6000 is no longer available, we still use a couple of them in our design office currently with Inventor 2019, these were purchased in 2008 and still work perfectly. Drivers were still available via spatialfreedom website, although couldnt access it today? These were also quarter of the price of the 3D Connexion items and cant knock the quality as these have been used eight hours a day for 13 years with no issues at all.
50,877,791
I have a dataset of 10 features. Three of these are categorical; when I apply one-hot encoding to these three, they blow up into 96 features. I reduced these 96 features into 20 by PCA. I plan to use the 20 principal components and the remaining 7 features as my final feature set. Is this a good idea: to combine principal components with actual features?
2018/06/15
[ "https://Stackoverflow.com/questions/50877791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2524115/" ]
`\d{0,2}` this [quantifier](https://www.regular-expressions.info/refrepeat.html) also matches a digit zero times so that would match the leading `-` in the 3rd example. In the [character class](https://www.regular-expressions.info/charclass.html) `[W,E]` you could omit the comma and list the characters you allow to match `[ENW]` If only the third group is optional you could try including the whitespace before the end of the line `$` [`^\d{2}(-\d{2})(-\d{2})? [ENW] $`](https://regex101.com/r/9C7qqw/1)
I have used this regular expression : `^(?!\-)\d{0,2}?(\-\d{0,2}).+\s(N|E|W|S)$` Using a `negative lookahead`, we have excluded anything that starts with a dash (`-`). * `(?!\-)` = `Starting at the current position in the expression, ensures that the given pattern will not match` * `\s(N|E|W|S)` matches anything with a space (`\s`) and one of the letters using OR operator `|`. * You may also use `\s+(N|E|W|S)`. * `+` = `Matches between one and unlimited times, as many times as possible, giving back as needed`
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
The `h4` tags which you re using as captions are block elements, which means, their width is 100% by default. Also, you have nothing that associates/unifies them with the images they belong to. The common way nowadays is to use a `figure`tag to wrap image and text, and put the text into a `figcaption`tag inside that figure tag. Then apply `text-align: center;` and `display: inline-block;` to the `figure` tag to center image and text inside and allow them to appear next to each other: ```css figure { text-align: center; display: inline-block; max-width: 100px; vertical-align: top; margin:10px; } ``` ```html <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image with a longer caption </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> ```
Images and Headers by default have `display` set to block, meaning they are on their own lines. `float` used to be the preferred way of achieving single-line display for block elements but it should be avoided as `float` has some weird behaviors. Instead we now use `display: inline-block;` or `display: inline;` - apply this to the elements you want on a single line and it will make it so! just example (not copying your code - just simple example script): HTML: ``` <div> <img src="one.png" class="inlineImg" /> <img src="two.png" class="inlineImg" /> <img src="three.png" class="inlineImg" /> </div> ``` CSS: ``` .inlineImg {display: inline;} ``` this will display the images on a single line (providing the div is big enough)
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
The `h4` tags which you re using as captions are block elements, which means, their width is 100% by default. Also, you have nothing that associates/unifies them with the images they belong to. The common way nowadays is to use a `figure`tag to wrap image and text, and put the text into a `figcaption`tag inside that figure tag. Then apply `text-align: center;` and `display: inline-block;` to the `figure` tag to center image and text inside and allow them to appear next to each other: ```css figure { text-align: center; display: inline-block; max-width: 100px; vertical-align: top; margin:10px; } ``` ```html <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image with a longer caption </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> ```
You can wrap the img- and h4-Tags with a div-Tag and make it float. ``` <div class="wrapper"> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> </div> ``` CSS: ``` .wrapper { float: left; } ``` Don't forget to unfloat afterwards.
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
Images and Headers by default have `display` set to block, meaning they are on their own lines. `float` used to be the preferred way of achieving single-line display for block elements but it should be avoided as `float` has some weird behaviors. Instead we now use `display: inline-block;` or `display: inline;` - apply this to the elements you want on a single line and it will make it so! just example (not copying your code - just simple example script): HTML: ``` <div> <img src="one.png" class="inlineImg" /> <img src="two.png" class="inlineImg" /> <img src="three.png" class="inlineImg" /> </div> ``` CSS: ``` .inlineImg {display: inline;} ``` this will display the images on a single line (providing the div is big enough)
``` .agencyproducts { position: relative; display: inline-flex; text-align: center; } ``` And you could put the main title outside of row div That should all make them horizontal. You may need to add some padding to separate the items tho.
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
The `h4` tags which you re using as captions are block elements, which means, their width is 100% by default. Also, you have nothing that associates/unifies them with the images they belong to. The common way nowadays is to use a `figure`tag to wrap image and text, and put the text into a `figcaption`tag inside that figure tag. Then apply `text-align: center;` and `display: inline-block;` to the `figure` tag to center image and text inside and allow them to appear next to each other: ```css figure { text-align: center; display: inline-block; max-width: 100px; vertical-align: top; margin:10px; } ``` ```html <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image with a longer caption </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> ```
The H4 will make them 'stack' vertically. Best to enclose each image and heading in it's own block or span, and on that div/span use " display: block; float: left;".
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
Images and Headers by default have `display` set to block, meaning they are on their own lines. `float` used to be the preferred way of achieving single-line display for block elements but it should be avoided as `float` has some weird behaviors. Instead we now use `display: inline-block;` or `display: inline;` - apply this to the elements you want on a single line and it will make it so! just example (not copying your code - just simple example script): HTML: ``` <div> <img src="one.png" class="inlineImg" /> <img src="two.png" class="inlineImg" /> <img src="three.png" class="inlineImg" /> </div> ``` CSS: ``` .inlineImg {display: inline;} ``` this will display the images on a single line (providing the div is big enough)
Put the image and the title below in a div, and float them all to the left. Like so— ```css .bullet-point { float: left; } .clear-float { clear: both; } ``` ```html <div class="bullet-point"> <img src="images/production.png" alt="Production"> <h4>2K / 4K PRODUCTION</h4> </div> <div class="bullet-point"> <img src="images/production.png" alt="Production"> <h4>2K / 4K PRODUCTION</h4> </div> . . .and so on <div class="clear-float"></div> ```
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
Images and Headers by default have `display` set to block, meaning they are on their own lines. `float` used to be the preferred way of achieving single-line display for block elements but it should be avoided as `float` has some weird behaviors. Instead we now use `display: inline-block;` or `display: inline;` - apply this to the elements you want on a single line and it will make it so! just example (not copying your code - just simple example script): HTML: ``` <div> <img src="one.png" class="inlineImg" /> <img src="two.png" class="inlineImg" /> <img src="three.png" class="inlineImg" /> </div> ``` CSS: ``` .inlineImg {display: inline;} ``` this will display the images on a single line (providing the div is big enough)
You can wrap the img- and h4-Tags with a div-Tag and make it float. ``` <div class="wrapper"> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> </div> ``` CSS: ``` .wrapper { float: left; } ``` Don't forget to unfloat afterwards.
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
Images and Headers by default have `display` set to block, meaning they are on their own lines. `float` used to be the preferred way of achieving single-line display for block elements but it should be avoided as `float` has some weird behaviors. Instead we now use `display: inline-block;` or `display: inline;` - apply this to the elements you want on a single line and it will make it so! just example (not copying your code - just simple example script): HTML: ``` <div> <img src="one.png" class="inlineImg" /> <img src="two.png" class="inlineImg" /> <img src="three.png" class="inlineImg" /> </div> ``` CSS: ``` .inlineImg {display: inline;} ``` this will display the images on a single line (providing the div is big enough)
Basicly the h4 element has automaticly a wifth of 100%, you can check this easily with the inspection tool of your browser. The easiest was is to put a div arround h and img element ``` <div class="containerIcon"> //img element //h element </div> .conainterIcon { display: block; width: 13%, //So they all fit in one line float: left; } ```
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
The `h4` tags which you re using as captions are block elements, which means, their width is 100% by default. Also, you have nothing that associates/unifies them with the images they belong to. The common way nowadays is to use a `figure`tag to wrap image and text, and put the text into a `figcaption`tag inside that figure tag. Then apply `text-align: center;` and `display: inline-block;` to the `figure` tag to center image and text inside and allow them to appear next to each other: ```css figure { text-align: center; display: inline-block; max-width: 100px; vertical-align: top; margin:10px; } ``` ```html <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image with a longer caption </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> ```
``` .agencyproducts { position: relative; display: inline-flex; text-align: center; } ``` And you could put the main title outside of row div That should all make them horizontal. You may need to add some padding to separate the items tho.
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
The `h4` tags which you re using as captions are block elements, which means, their width is 100% by default. Also, you have nothing that associates/unifies them with the images they belong to. The common way nowadays is to use a `figure`tag to wrap image and text, and put the text into a `figcaption`tag inside that figure tag. Then apply `text-align: center;` and `display: inline-block;` to the `figure` tag to center image and text inside and allow them to appear next to each other: ```css figure { text-align: center; display: inline-block; max-width: 100px; vertical-align: top; margin:10px; } ``` ```html <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image with a longer caption </figcaption> </figure> <figure> <img src="http://placehold.it/80x80/cac"> <figcaption> This is an image </figcaption> </figure> ```
Basicly the h4 element has automaticly a wifth of 100%, you can check this easily with the inspection tool of your browser. The easiest was is to put a div arround h and img element ``` <div class="containerIcon"> //img element //h element </div> .conainterIcon { display: block; width: 13%, //So they all fit in one line float: left; } ```
44,822,470
I have a row with seven small images and a heading which I need to stack horizontally but they're stacking vertically. This is how it looks - [![Vertical not horizontal](https://i.stack.imgur.com/K0rlk.png)](https://i.stack.imgur.com/K0rlk.png) I'm sure this is really simple but I'm stumped. I'm using reset & skeleton grid. This is the relevant code - **HTML** ``` <section id="products"> <div class="container"> <div class="row"> <div class="twelve columns agencyproducts"> <h2>WHAT PRODUCT ARE YOU INTERESTED IN?</h2> <img src="images/production.png" alt="Production" style="width:50px;height:50px;"> <h4>2K / 4K PRODUCTION</h4> <img src="images/post-production.png" alt="Post-Production" style="width:50px;height:50px;"> <h4>POST PRODUCTION</h4> <img src="images/animation.png" alt="Animation" style="width:50px;height:50px;"> <h4>2D / 3D ANIMATION</h4> <img src="images/ADHOC.png" alt="ADHOC" style="width:50px;height:50px;"> <h4>ADHOC</h4> <img src="images/interactive.png" alt="Interactive" style="width:50px;height:50px;"> <h4>INTERACTIVE & PERSONALISED</h4> <img src="images/tv-adverts.png" alt="TV ADVERTS" style="width:50px;height:50px;"> <h4>TV ADVERTS</h4> <img src="images/360.png" alt="360 Video and VR" style="width:50px;height:50px;"> <h4>360 VIDEO & VIRTUAL REALITY</h4> </div> </div> ``` **CSS** ``` section#products { height: 700px; max-width: 100% } .row { height: 350px; max-width: 100%; } .agencyproducts { position: relative; display: block; text-align: center; } .agencyproducts img { position: relative; line-height: 1; top: 50%; } .agencyproducts h4 { display: block; text-align: center; font-size: 10px; } ```
2017/06/29
[ "https://Stackoverflow.com/questions/44822470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3521315/" ]
Images and Headers by default have `display` set to block, meaning they are on their own lines. `float` used to be the preferred way of achieving single-line display for block elements but it should be avoided as `float` has some weird behaviors. Instead we now use `display: inline-block;` or `display: inline;` - apply this to the elements you want on a single line and it will make it so! just example (not copying your code - just simple example script): HTML: ``` <div> <img src="one.png" class="inlineImg" /> <img src="two.png" class="inlineImg" /> <img src="three.png" class="inlineImg" /> </div> ``` CSS: ``` .inlineImg {display: inline;} ``` this will display the images on a single line (providing the div is big enough)
The H4 will make them 'stack' vertically. Best to enclose each image and heading in it's own block or span, and on that div/span use " display: block; float: left;".
709,848
[![enter image description here](https://i.stack.imgur.com/10q7j.jpg)](https://i.stack.imgur.com/10q7j.jpg) Applying kirchhoff's second law to the first loop, the current in the upper branch remains determined and is $2.4$ A to the right (if $i$ is to the right then $-10i + 24 = 0$). Then the current in the upper branch of the second loop must be $8 + 6 + 2.4 = 16.4$ A to the right. But how can it be? Using kirchhoff's second law with the second loop it is found that the current in the upper branch must be $17.6$ A to the left (if $i$ is to the right then $-5i - 88 = 0$). All this assuming current generator have negligible resistance. I'm doing some stupid mistake that I can't see.
2022/05/21
[ "https://physics.stackexchange.com/questions/709848", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/-1/" ]
The circuit may be feasible if the circles represent power supplies (constant current or voltage) rather than meter readings.
Loop analysis necessitates a singe value of loop current. Just like node analysis necessitates a single value of node voltage. In your case, you are getting two different values of current in each branch of each loop instead of one loop current. In reality the current leaving the bottom branch of each loop must enter the top branch so that no current flows between the two loops. I believe the root of the inconsistency is assuming two ideal current sources. This gives you two different values for a single loop current. Real current sources have impedance (resistance) in parallel. If you include resistors in parallel with the two current sources you will have no inconsistency. A similar inconsistency results when attempting to connect two ideal voltage sources with different emfs in parallel, giving you two different values of voltage for a single point. Real voltage sources have impedance (resistance) in series. I have replicated your circuit below, adding resistors in parallel with the current sources and a resistor in series with the voltage source so that they represent actual current and voltage sources. Note that adding the resistors for the current generators does not alter the value of the current. But there is now a voltage drop across the generator resistances in the bottom branches equal to the current generator times the resistance. The voltage drop across $R\_1$ is $6R\_1$ and across $R\_2$ is $8R\_2$. Each current generator and its parallel resistance are themselves loops. The same current is now in the bottom and top branches of each loop, so there is no current flowing between the loops. The loops are independent of each other because they do not have any circuit elements in common. Hope this helps. [![enter image description here](https://i.stack.imgur.com/hMzrx.jpg)](https://i.stack.imgur.com/hMzrx.jpg)
709,848
[![enter image description here](https://i.stack.imgur.com/10q7j.jpg)](https://i.stack.imgur.com/10q7j.jpg) Applying kirchhoff's second law to the first loop, the current in the upper branch remains determined and is $2.4$ A to the right (if $i$ is to the right then $-10i + 24 = 0$). Then the current in the upper branch of the second loop must be $8 + 6 + 2.4 = 16.4$ A to the right. But how can it be? Using kirchhoff's second law with the second loop it is found that the current in the upper branch must be $17.6$ A to the left (if $i$ is to the right then $-5i - 88 = 0$). All this assuming current generator have negligible resistance. I'm doing some stupid mistake that I can't see.
2022/05/21
[ "https://physics.stackexchange.com/questions/709848", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/-1/" ]
If what is asked is V on the left, you may assume an ideal voltmeter drawing zero current. Then, your circuit is a big loop producing a voltage but zero current. The big loop is composed of 5 things in series: three loops and two resistors. Because they are in series, their voltages add, but their through currents are zero. There's no current through the 13Ω and 9Ω resistors. They contribute nothing to the voltage. So, all you have to do is analyze each loop separately. Figure out what the current is in each current loop, figure out what voltage that produces across their terminals. The other loop is easier. The rest is left to the student.
The circuit may be feasible if the circles represent power supplies (constant current or voltage) rather than meter readings.
709,848
[![enter image description here](https://i.stack.imgur.com/10q7j.jpg)](https://i.stack.imgur.com/10q7j.jpg) Applying kirchhoff's second law to the first loop, the current in the upper branch remains determined and is $2.4$ A to the right (if $i$ is to the right then $-10i + 24 = 0$). Then the current in the upper branch of the second loop must be $8 + 6 + 2.4 = 16.4$ A to the right. But how can it be? Using kirchhoff's second law with the second loop it is found that the current in the upper branch must be $17.6$ A to the left (if $i$ is to the right then $-5i - 88 = 0$). All this assuming current generator have negligible resistance. I'm doing some stupid mistake that I can't see.
2022/05/21
[ "https://physics.stackexchange.com/questions/709848", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/-1/" ]
If what is asked is V on the left, you may assume an ideal voltmeter drawing zero current. Then, your circuit is a big loop producing a voltage but zero current. The big loop is composed of 5 things in series: three loops and two resistors. Because they are in series, their voltages add, but their through currents are zero. There's no current through the 13Ω and 9Ω resistors. They contribute nothing to the voltage. So, all you have to do is analyze each loop separately. Figure out what the current is in each current loop, figure out what voltage that produces across their terminals. The other loop is easier. The rest is left to the student.
Loop analysis necessitates a singe value of loop current. Just like node analysis necessitates a single value of node voltage. In your case, you are getting two different values of current in each branch of each loop instead of one loop current. In reality the current leaving the bottom branch of each loop must enter the top branch so that no current flows between the two loops. I believe the root of the inconsistency is assuming two ideal current sources. This gives you two different values for a single loop current. Real current sources have impedance (resistance) in parallel. If you include resistors in parallel with the two current sources you will have no inconsistency. A similar inconsistency results when attempting to connect two ideal voltage sources with different emfs in parallel, giving you two different values of voltage for a single point. Real voltage sources have impedance (resistance) in series. I have replicated your circuit below, adding resistors in parallel with the current sources and a resistor in series with the voltage source so that they represent actual current and voltage sources. Note that adding the resistors for the current generators does not alter the value of the current. But there is now a voltage drop across the generator resistances in the bottom branches equal to the current generator times the resistance. The voltage drop across $R\_1$ is $6R\_1$ and across $R\_2$ is $8R\_2$. Each current generator and its parallel resistance are themselves loops. The same current is now in the bottom and top branches of each loop, so there is no current flowing between the loops. The loops are independent of each other because they do not have any circuit elements in common. Hope this helps. [![enter image description here](https://i.stack.imgur.com/hMzrx.jpg)](https://i.stack.imgur.com/hMzrx.jpg)
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
> > why in C++ the main() function is not overloaded to take an > std::vector argv instead of the old char\* argv[] > > > Because that demands **dependency on `<string>` library**. C++'s philosophy is always *"don't pay for what you don't use*". If someone doesn't want the automatic memory management offered by `string` then they can't be enforced. *2nd view*: If some platform doesn't have any library support then you cannot start your C++ program!! On the contrary, `int` and `char**` arguments are built-in and independent types. One can always write custom wrapper on `main()` which does exactly whatever is the need. **Edit**: On AProgrammer's comment: Suppose that `main(vector<string>)` is allowed; then if a platform conforms to all C++ features, but don't have standard library support then it will become non-standard compliant.
Basically, a std::vector is NOT the same (in memory layout or anything) as an array of char \*. To permit this, you'd have to make the compiler recognise the new main declaration and add a wrapper on entry that created a vector of strings. Given you were doing that, you might as well throw argc away as well, and have the declaration of main be ``` int main(std::vector<std::string> argv) ``` But it's work for the compiler. You'd have to get a lot of people who thought it was worthwhile. Otherwise you can just do it yourself ``` int main(int argc, char **argv) { std::vector<std::string> args; args.reserve(argc); for (std::size_t arg = 0; arg < argc; ++arg) { args.push_back(argv[i]); } return mymain(args); } ``` Code is not guaranteed to compile or work cos I just wrote it off the top of my head. or (better, thanks to AProgrammer) ``` int main(int argc, char **argv) { return mymain(std::vector<std::string>(argv, argv + argc)); } ```
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
Why isn't it in the standard? Simple: Because nobody *proposed* it. Things go into the C++ standard because someone writes a proposal for it, then gets other people to vote on it and incorporate it. Unless someone actually *wants* it to happen, it doesn't get to happen. And considering how trivial this feature really is: ``` int main(int argc, char **argv) { std::vector<std::string> args(argv, argv + argc); ... } ``` There just isn't any real *need* for it. It's a convenience function, and it doesn't even make things that convenient compared to the alternative.
> > why in C++ the main() function is not overloaded to take an > std::vector argv instead of the old char\* argv[] > > > Because that demands **dependency on `<string>` library**. C++'s philosophy is always *"don't pay for what you don't use*". If someone doesn't want the automatic memory management offered by `string` then they can't be enforced. *2nd view*: If some platform doesn't have any library support then you cannot start your C++ program!! On the contrary, `int` and `char**` arguments are built-in and independent types. One can always write custom wrapper on `main()` which does exactly whatever is the need. **Edit**: On AProgrammer's comment: Suppose that `main(vector<string>)` is allowed; then if a platform conforms to all C++ features, but don't have standard library support then it will become non-standard compliant.
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
> > why in C++ the main() function is not overloaded to take an > std::vector argv instead of the old char\* argv[] > > > Because that demands **dependency on `<string>` library**. C++'s philosophy is always *"don't pay for what you don't use*". If someone doesn't want the automatic memory management offered by `string` then they can't be enforced. *2nd view*: If some platform doesn't have any library support then you cannot start your C++ program!! On the contrary, `int` and `char**` arguments are built-in and independent types. One can always write custom wrapper on `main()` which does exactly whatever is the need. **Edit**: On AProgrammer's comment: Suppose that `main(vector<string>)` is allowed; then if a platform conforms to all C++ features, but don't have standard library support then it will become non-standard compliant.
It would be trivial for a compiler to compile a main defined as ``` int main(std::vector<std::string> args) { ... } ``` as it has been written as ``` int main(int __argc, char **__argv) { std::vector<std::string> args(__argv, __argv+__argc); ... } ``` It would be even about as easy to allow any container, even custom one, and not just `std::vector<std::string>`. But it isn't standard because ­— standard answer to *why isn't this in the standard* — nobody proposed it and convinced enough people that it was a good idea. I don't think there was a proposition, so there is probably no rationale for its rejection. The change is probably to simple for most of involved people to bother.
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
> > why in C++ the main() function is not overloaded to take an > std::vector argv instead of the old char\* argv[] > > > Because that demands **dependency on `<string>` library**. C++'s philosophy is always *"don't pay for what you don't use*". If someone doesn't want the automatic memory management offered by `string` then they can't be enforced. *2nd view*: If some platform doesn't have any library support then you cannot start your C++ program!! On the contrary, `int` and `char**` arguments are built-in and independent types. One can always write custom wrapper on `main()` which does exactly whatever is the need. **Edit**: On AProgrammer's comment: Suppose that `main(vector<string>)` is allowed; then if a platform conforms to all C++ features, but don't have standard library support then it will become non-standard compliant.
The main reason, I suspect, is because the usual implementation is to make it an `extern "C"` function, with varargs. In a lot of implementations, it is the C runtime library which calls main. There are many ways around this, but none of them seem worth the bother, given how easy it is to convert the arguments to whatever you want.
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
Why isn't it in the standard? Simple: Because nobody *proposed* it. Things go into the C++ standard because someone writes a proposal for it, then gets other people to vote on it and incorporate it. Unless someone actually *wants* it to happen, it doesn't get to happen. And considering how trivial this feature really is: ``` int main(int argc, char **argv) { std::vector<std::string> args(argv, argv + argc); ... } ``` There just isn't any real *need* for it. It's a convenience function, and it doesn't even make things that convenient compared to the alternative.
Basically, a std::vector is NOT the same (in memory layout or anything) as an array of char \*. To permit this, you'd have to make the compiler recognise the new main declaration and add a wrapper on entry that created a vector of strings. Given you were doing that, you might as well throw argc away as well, and have the declaration of main be ``` int main(std::vector<std::string> argv) ``` But it's work for the compiler. You'd have to get a lot of people who thought it was worthwhile. Otherwise you can just do it yourself ``` int main(int argc, char **argv) { std::vector<std::string> args; args.reserve(argc); for (std::size_t arg = 0; arg < argc; ++arg) { args.push_back(argv[i]); } return mymain(args); } ``` Code is not guaranteed to compile or work cos I just wrote it off the top of my head. or (better, thanks to AProgrammer) ``` int main(int argc, char **argv) { return mymain(std::vector<std::string>(argv, argv + argc)); } ```
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
It would be trivial for a compiler to compile a main defined as ``` int main(std::vector<std::string> args) { ... } ``` as it has been written as ``` int main(int __argc, char **__argv) { std::vector<std::string> args(__argv, __argv+__argc); ... } ``` It would be even about as easy to allow any container, even custom one, and not just `std::vector<std::string>`. But it isn't standard because ­— standard answer to *why isn't this in the standard* — nobody proposed it and convinced enough people that it was a good idea. I don't think there was a proposition, so there is probably no rationale for its rejection. The change is probably to simple for most of involved people to bother.
Basically, a std::vector is NOT the same (in memory layout or anything) as an array of char \*. To permit this, you'd have to make the compiler recognise the new main declaration and add a wrapper on entry that created a vector of strings. Given you were doing that, you might as well throw argc away as well, and have the declaration of main be ``` int main(std::vector<std::string> argv) ``` But it's work for the compiler. You'd have to get a lot of people who thought it was worthwhile. Otherwise you can just do it yourself ``` int main(int argc, char **argv) { std::vector<std::string> args; args.reserve(argc); for (std::size_t arg = 0; arg < argc; ++arg) { args.push_back(argv[i]); } return mymain(args); } ``` Code is not guaranteed to compile or work cos I just wrote it off the top of my head. or (better, thanks to AProgrammer) ``` int main(int argc, char **argv) { return mymain(std::vector<std::string>(argv, argv + argc)); } ```
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
The main reason, I suspect, is because the usual implementation is to make it an `extern "C"` function, with varargs. In a lot of implementations, it is the C runtime library which calls main. There are many ways around this, but none of them seem worth the bother, given how easy it is to convert the arguments to whatever you want.
Basically, a std::vector is NOT the same (in memory layout or anything) as an array of char \*. To permit this, you'd have to make the compiler recognise the new main declaration and add a wrapper on entry that created a vector of strings. Given you were doing that, you might as well throw argc away as well, and have the declaration of main be ``` int main(std::vector<std::string> argv) ``` But it's work for the compiler. You'd have to get a lot of people who thought it was worthwhile. Otherwise you can just do it yourself ``` int main(int argc, char **argv) { std::vector<std::string> args; args.reserve(argc); for (std::size_t arg = 0; arg < argc; ++arg) { args.push_back(argv[i]); } return mymain(args); } ``` Code is not guaranteed to compile or work cos I just wrote it off the top of my head. or (better, thanks to AProgrammer) ``` int main(int argc, char **argv) { return mymain(std::vector<std::string>(argv, argv + argc)); } ```
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
Why isn't it in the standard? Simple: Because nobody *proposed* it. Things go into the C++ standard because someone writes a proposal for it, then gets other people to vote on it and incorporate it. Unless someone actually *wants* it to happen, it doesn't get to happen. And considering how trivial this feature really is: ``` int main(int argc, char **argv) { std::vector<std::string> args(argv, argv + argc); ... } ``` There just isn't any real *need* for it. It's a convenience function, and it doesn't even make things that convenient compared to the alternative.
It would be trivial for a compiler to compile a main defined as ``` int main(std::vector<std::string> args) { ... } ``` as it has been written as ``` int main(int __argc, char **__argv) { std::vector<std::string> args(__argv, __argv+__argc); ... } ``` It would be even about as easy to allow any container, even custom one, and not just `std::vector<std::string>`. But it isn't standard because ­— standard answer to *why isn't this in the standard* — nobody proposed it and convinced enough people that it was a good idea. I don't think there was a proposition, so there is probably no rationale for its rejection. The change is probably to simple for most of involved people to bother.
12,072,603
I wish to load the information from the text file onto listview. Please help me with the same code. The information I am getting while reading is in following format ``` 1,demo,time,date: 2,sad,dad,sad: ``` I need to display the data in such a way that for int values say 0/1 there should be an image. Next demo/sad below that time/dad and atlast date must be displayed. Please help me for the same.
2012/08/22
[ "https://Stackoverflow.com/questions/12072603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1586619/" ]
Why isn't it in the standard? Simple: Because nobody *proposed* it. Things go into the C++ standard because someone writes a proposal for it, then gets other people to vote on it and incorporate it. Unless someone actually *wants* it to happen, it doesn't get to happen. And considering how trivial this feature really is: ``` int main(int argc, char **argv) { std::vector<std::string> args(argv, argv + argc); ... } ``` There just isn't any real *need* for it. It's a convenience function, and it doesn't even make things that convenient compared to the alternative.
The main reason, I suspect, is because the usual implementation is to make it an `extern "C"` function, with varargs. In a lot of implementations, it is the C runtime library which calls main. There are many ways around this, but none of them seem worth the bother, given how easy it is to convert the arguments to whatever you want.
679,321
We know that $\tan(\pi/2)$ is undefined, and $\cot(\pi/2) = 0$. But $\cot(x) = \frac{\cos(x)}{\sin(x)} = \frac{1}{\tan(x)}$. So how is it possible that for some value $x$, $\tan(x)$ is undefined but $\,1/\tan(x)$ is defined?
2014/02/17
[ "https://math.stackexchange.com/questions/679321", "https://math.stackexchange.com", "https://math.stackexchange.com/users/54916/" ]
The identity $\cot(x) = \frac{1}{\tan(x)}$ only works where they are both defined. Really, this isn't some sort of definition, but rather a consequence of the fact that $$ \tan(x) = \frac{\sin(x)}{\cos(x)}, \quad \cot(x) = \frac{\cos(x)}{\sin(x)} $$ and if you treat these functions as variables, then it is clear that the identity holds. But this isn't completely accurate, and as you have noted, it doesn't hold for $x$ being an integer multiple of $\frac{\pi}{2}$. In the field of algebraic geometry an identity like $\cot(x) = \frac{1}{\tan(x)}$ would be called a *birational equivalence*, rather than equality, to reflect this fact. It means the functions are equal wherever they are defined (and that they are defined almost everywhere). If there is some sort of intuition to get out of this, it could be that $\cot(x)$ and $\frac{1}{\tan(x)}$ can be considered mostly equal as *functions*, but not necessarily when as evaluations at specific *points*. So as long as you are manipulating expressions where the functions act like variables, you can consider them equal, but add the constraint $x \neq \frac{n\pi}{2}$ as you go along to help reminding yourself that it is not *always* true.
Why we say $\tan(\pi/2)$ is undefined. Since $\frac{\sin(\pi/2)}{\cos(\pi/2)}$ and $\cos(\pi/2)=0$, we should say $\tan(\pi/2)$ is undefined. Note that $\frac{\*}{0}$ always is undefined.
679,321
We know that $\tan(\pi/2)$ is undefined, and $\cot(\pi/2) = 0$. But $\cot(x) = \frac{\cos(x)}{\sin(x)} = \frac{1}{\tan(x)}$. So how is it possible that for some value $x$, $\tan(x)$ is undefined but $\,1/\tan(x)$ is defined?
2014/02/17
[ "https://math.stackexchange.com/questions/679321", "https://math.stackexchange.com", "https://math.stackexchange.com/users/54916/" ]
The identity $\cot(x) = \frac{1}{\tan(x)}$ only works where they are both defined. Really, this isn't some sort of definition, but rather a consequence of the fact that $$ \tan(x) = \frac{\sin(x)}{\cos(x)}, \quad \cot(x) = \frac{\cos(x)}{\sin(x)} $$ and if you treat these functions as variables, then it is clear that the identity holds. But this isn't completely accurate, and as you have noted, it doesn't hold for $x$ being an integer multiple of $\frac{\pi}{2}$. In the field of algebraic geometry an identity like $\cot(x) = \frac{1}{\tan(x)}$ would be called a *birational equivalence*, rather than equality, to reflect this fact. It means the functions are equal wherever they are defined (and that they are defined almost everywhere). If there is some sort of intuition to get out of this, it could be that $\cot(x)$ and $\frac{1}{\tan(x)}$ can be considered mostly equal as *functions*, but not necessarily when as evaluations at specific *points*. So as long as you are manipulating expressions where the functions act like variables, you can consider them equal, but add the constraint $x \neq \frac{n\pi}{2}$ as you go along to help reminding yourself that it is not *always* true.
1. $\tan$ and $\cot$ have different domains. 2. $\cot x\equiv\dfrac1{\tan x}.$ This is an [identity](https://math.stackexchange.com/a/4254850/21813), and reads: $\cot x=\dfrac1{\tan x}$ is universally true wherever both functions are defined. User SassatelliGiulio's [comment](https://math.stackexchange.com/questions/4520032/domain-of-the-tan-function-and-cot-function-for-pi-2#comment9494443_4520032) nicely sums it up: “$\cot x=\frac1{\tan x}$ is an identity that holds in the intersection of the domains. It shouldn't be read as implying that the functions have the same domain.” Alternatively, we can *define* $\cot x:=\dfrac1{\tan x},$ stipulating the domain of $\cot$ as $\{x\in\mathbb R\mid \forall n{\in}\mathbb Z\;x\ne n\pi\}.$
53,020,409
I am trying to write a code, that reads from a file that has products of apple listed in it. I also have two classes that store the data from the file in array of the objects from those files. But whenever I try to get values from the array of those objects, it always remains null. I think something is going wrong with reading those values from file, but I can't spot which. Also, there's no debugger at my disposal currently. This is the code which I am using to read file and store its values in classes. ```java Scanner fScanner=null; FileWriter fw = null; try { fScanner = new Scanner(new File("apple.txt")); } catch (FileNotFoundException e) { System.out.println(e.toString()); } while(fScanner.hasNextLine()) { String line = fScanner.nextLine(); Scanner lineScanner = new Scanner(line); if(lineScanner.next().equals("IPHONE")) countIphone++; else if(lineScanner.next().equals("IPAD")) countIpad++; } Iphone[] iphone = new Iphone[countIphone]; Ipad[] ipad = new Ipad[countIpad]; while(fScanner.hasNextLine()) { String line = fScanner.nextLine(); Scanner lineScanner = new Scanner(line); if(lineScanner.next().equals("IPHONE")) { for(int i=0;i<countIphone;i++) { iphone[i].setModel("IPHONE"+lineScanner.useDelimiter(",").next()); iphone[i].setScreenSize(lineScanner.useDelimiter(",").next()); iphone[i].setProcessor(lineScanner.useDelimiter(",").next()); iphone[i].setSimType(lineScanner.useDelimiter(",").next()); iphone[i].setColor(lineScanner.useDelimiter(",").next()); iphone[i].setROM(lineScanner.useDelimiter(",").next()); iphone[i].setIs3DTouch(lineScanner.useDelimiter(",").next()); iphone[i].setPrice(lineScanner.useDelimiter(",").next()); } } else if(lineScanner.next().equals("IPAD")) { for(int i=0;i<countIpad;i++) { ipad[i].setModel("IPAD"+lineScanner.useDelimiter(",").next()); ipad[i].setScreenSize(lineScanner.useDelimiter(",").next()); ipad[i].setProcessor(lineScanner.useDelimiter(",").next()); ipad[i].setIsWifi(lineScanner.useDelimiter(",").next()); ipad[i].setColor(lineScanner.useDelimiter(",").next()); ipad[i].setMemory(lineScanner.useDelimiter(",").next()); ipad[i].setPrice(lineScanner.useDelimiter(",").next()); } } } ``` The file looks like this: ```text IPHONE 7, 4.7, A10, GSM, JET BLACK, 32GB, TRUE, 700 IPAD AIR 2, 9.7, A8, TRUE, SILVER, 64GB, 400 IPHONE SE, 4, A9, CDMA, SILVER, 16GB, FALSE, 490 IPAD PRO, 9.7, A9, TRUE, SPACE GREY, 32GB, 650 IPHONE X, 7, A11, LTE, BLACK, 128GB, TRUE, 999 IPAD PRO X, 12, A12, TRUE, SPACE GREY, 256GB, 700 ```
2018/10/27
[ "https://Stackoverflow.com/questions/53020409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
@dasblinkenlight has pointed out the reason why `iphone` and `ipad` are empty. But there are still some things wrong: * While iterating `for(int i=0;i<countIphone;i++) { ... }` `iphone[i]` is `null`. You never assigned `iphone[i] = new Iphone();`. Thus trying to invoke a method like `iphone[i].setModel(...)` will throw a `NullPointerException`. The same applies to the iteration over `ipad`. * Something less obvious is that calling `new Scanner(new File("apple.txt"))` you're opening a resource. It's not closed in the code. If you want still use `Scanner` work with the [try-resource-statement](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html). I would like to suggest another design and using [nio-API](https://docs.oracle.com/javase/10/docs/api/java/nio/file/package-summary.html) and [stream-API](https://docs.oracle.com/javase/10/docs/api/java/util/stream/package-summary.html). At first I define an enum for the known devices: ``` public enum Device { IPHONE, IPAD; public static Device byName(String name) { return Arrays.stream(values()) .filter(d -> name.startsWith(d.toString())) .findAny() .orElseThrow(() -> new IllegalArgumentException(String.format("Unknown device name %s", name))); } } ``` The method `Device.byName` returns for the first word in a line from *apple.txt* the corresponding `Device`. For each device I define a `Function` which acts as a factory. It takes a split line (split by `", "`) from *apple.txt* and returns the appropriate instance. ``` private static Function<String[], Iphone> toIphone() { return line -> { Iphone iphone = new Iphone(); iphone.setModel(Device.IPHONE.toString() + line[0].split(" ")[1]); iphone.setScreenSize(line[1]); iphone.setProcessor(line[2]); iphone.setSimType(line[3]); iphone.setColor(line[4]); iphone.setROM(line[5]); iphone.setIs3DTouch(line[6]); iphone.setPrice(line[7]); return iphone; }; } private static Function<String[], Ipad> toIpad() { return line -> { Ipad ipad = new Ipad(); ipad.setModel(Device.IPAD.toString() + line[0].split(" ")[1]); ipad.setScreenSize(line[1]); ipad.setProcessor(line[2]); ipad.setIsWifi(line[3]); ipad.setColor(line[4]); ipad.setMemory(line[5]); ipad.setPrice(line[6]); return ipad; }; } ``` To decide which method to call I define a method which takes a split line representing a device from *apple.txt*. It calls `Device.byName` passing in the first element of the split line. ``` private static Device classify(String[] device) { return Device.byName(device[0]); } ``` Now we can use the above code to do the file processing like that: ``` public static void main(String[] args) throws IOException { Map<Device, List<String[]>> devices = Files .lines(new File("./apple.txt").toPath()) .map(l -> l.split(", ")) .collect(Collectors.groupingBy(Example::classify)); Iphone[] iphones = devices.get(Device.IPHONE).stream() .map(toIphone()) .toArray(Iphone[]::new); Ipad[] ipads = devices.get(Device.IPAD).stream() .map(toIpad()) .toArray(Ipad[]::new); } ``` Using `Files.lines` we don't need to worry about closing the read `File`. By calling `Collectors.groupingBy(Example::classify)` we receive a `Map` from the `Stream` which has instances of `Device` as keys. For a `Devices` it returns a `List` with all corresponding instances.
Your algorithm goes through the file twice: * First `while(fScanner.hasNextLine())` loop counts iphones and ipads in the file * Second `while(fScanner.hasNextLine())` loop reads the actual data The problem is that once the first loop is over, all the input has been consumed. You can fix this problem by closing and re-opening the scanner. However, your code has other problems - `for` loops inside the conditionals assume that all iphones and all ipads are in the file together, while that is not so. You you fix this by combining the scanning loops and using a resizable container for iphones and ipads: ``` List<Iphone> iphones = new ArrayList<>(); List<Ipad> ipads = new ArrayList<>(); ```
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
Popen is defined in the subprocess module ``` import subprocess ... subprocess.Popen(...) ``` Or: ``` from subprocess import Popen Popen(...) ```
You should be using os.popen() if you simply import os.
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
Popen is defined in the subprocess module ``` import subprocess ... subprocess.Popen(...) ``` Or: ``` from subprocess import Popen Popen(...) ```
This looks like Popen from the subprocess module (python >= 2.4) ``` from subprocess import Popen ```
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
When you import a module, the module's members don't become part of the global namespace: you still have to prefix them with `modulename.`. So, you have to say ``` import os process = os.popen(command, mode, bufsize) ``` Alternatively, you can use the `from module import names` syntax to import things into the global namespace: ``` from os import popen # Or, from os import * to import everything process = popen(command, mode, bufsize) ```
This looks like Popen from the subprocess module (python >= 2.4) ``` from subprocess import Popen ```
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
you should do: ``` import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc. ```
When you import a module, the module's members don't become part of the global namespace: you still have to prefix them with `modulename.`. So, you have to say ``` import os process = os.popen(command, mode, bufsize) ``` Alternatively, you can use the `from module import names` syntax to import things into the global namespace: ``` from os import popen # Or, from os import * to import everything process = popen(command, mode, bufsize) ```
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
When you import a module, the module's members don't become part of the global namespace: you still have to prefix them with `modulename.`. So, you have to say ``` import os process = os.popen(command, mode, bufsize) ``` Alternatively, you can use the `from module import names` syntax to import things into the global namespace: ``` from os import popen # Or, from os import * to import everything process = popen(command, mode, bufsize) ```
You should be using os.popen() if you simply import os.
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
you should do: ``` import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc. ```
If your import looks like this: ``` import os ``` Then you need to reference the things included in os like this: ``` os.popen() ``` If you dont want to do that, you can change your import to look like this: ``` from os import * ``` Which is not recommended because it can lead to namespace ambiguities (things in your code conflicting with things imported elsewhere.) You could also just do: ``` from os import popen ``` Which is more explicit and easier to read than from os import \*
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
This looks like Popen from the subprocess module (python >= 2.4) ``` from subprocess import Popen ```
You should be using os.popen() if you simply import os.
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
you should do: ``` import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc. ```
This looks like Popen from the subprocess module (python >= 2.4) ``` from subprocess import Popen ```
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
you should do: ``` import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc. ```
Popen is defined in the subprocess module ``` import subprocess ... subprocess.Popen(...) ``` Or: ``` from subprocess import Popen Popen(...) ```
1,007,855
Working on some code and I'm given the error when running it from the command prompt... ``` NameError: name 'Popen' is not defined ``` but I've imported both `import os` and `import sys`. Here's part of the code ``` exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0] ``` Am I missing something elementary? I wouldn't doubt it. Thanks!
2009/06/17
[ "https://Stackoverflow.com/questions/1007855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/113976/" ]
you should do: ``` import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc. ```
You should be using os.popen() if you simply import os.