底部对齐div而不指定父容器高度(Bottom aligning div without specifying parent container height)
我有一些像这样的HTML
<div class="gRow"> <div class="cell c9 right last">Text</div> <div class="cell c8 right gCol8">Long text wrapped over multiple lines</div> <div class="cell c7 right gCol7">Text</div> </div>
看到这个小提琴: http : //jsfiddle.net/LmZYE/
我想要的是让两个“Text”div与gRow div的底部对齐。
我不知道渲染时gRow的高度,因为文本随所选语言而变化。 我已经尝试定位gRow亲戚和我的内部div的绝对,底部:0但是徒劳无功。
我可以做我想做的事情或者我需要知道gRow div的高度吗?
编辑:忘了一件事:我希望从gRow的顶部到底部有一个正确的边界。
提前致谢!
I have some html like this
<div class="gRow"> <div class="cell c9 right last">Text</div> <div class="cell c8 right gCol8">Long text wrapped over multiple lines</div> <div class="cell c7 right gCol7">Text</div> </div>
See this fiddle: http://jsfiddle.net/LmZYE/
What I would like is to have the two "Text" div's align to the bottom of the gRow div.
I don't know the height of gRow at render time as the text changes with selected language. I have tried positioning gRow relative and my inner div's absolute, bottom:0 but in vain.
Can I do what I'm trying to do or do I need to know the height of the gRow div?
EDIT: Forgot one thing: I would like to have a right border going all the way from the top to the bottom of gRow.
Thanks in advance!
原文:https://stackoverflow.com/questions/16359577
最满意答案
将一个不可见的按钮放置在文本区域上,方法如下:
UIButton* button = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; button.frame =CGRectMake(your parameters here); button.showsTouchWhenHighlighted=YES; // handy for debugging [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];并将其添加为子视图。 根据你想要实现的以及你的UITextField的内容,你需要添加的内容可能会有所不同。
Put an invisible button over the text area by making a button like this:
UIButton* button = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; button.frame =CGRectMake(your parameters here); button.showsTouchWhenHighlighted=YES; // handy for debugging [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];and adding it as a subview. Depending on what you're trying to achieve and what your UITextField is contained in, what you need to add it to may differ.
相关问答
更多-
我假设您正在尝试决定是否提供JavaScript增强内容。 最好的实现会很干净地降级,所以该网站仍然运行没有JavaScript。 我也假设您的意思是服务器端检测,而不是使用
-
这应该会让你朝着正确的方向前进。 This should push you in the right direction.
-
UITapGestureRecognizer *gr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)]; [self.view addGestureRecognizer:gr]; // if not using ARC, you should [gr release]; // mySensitiveRect coords are in the coordinate system of ...
-
Tun / tap尝试看起来像一个普通的以太网控制器,但是tap设备本身就像任何其他文件描述符一样被访问。 由于它伪装成一个以太网控制器,所以你必须事先知道以太网帧本身是多大的 - 它来自于tap设备所连接的软件桥或者原始以太网中的“length”字段帧。 这当然只能是tap设备的最大MTU大小,通常默认为1500字节。 因此,在对tap设备的文件描述符执行read()之前,您必须弄清楚以太网帧实际上有多大。 Tun/tap tries to look like a regular ethernet con ...
-
检测iPhone上遥控器上一个音轨按钮的双击(Detect double tap on previous track button of remote control on iPhone)[2022-03-18]
您无法检测操作系统本身的触摸,在您的情况下是多任务栏。 您只能检测应用范围内的触摸。 当用户显示多任务栏时,您的应用程序调用- (void)applicationWillResignActive:(UIApplication *)application方法 You cannot detect the touches of the OS itself, in your case the multitasking bar. You can only detect touches within the bound ... -
您可以使用以下代码段来检测触摸屏设备: function is_touch_device() { try { document.createEvent("TouchEvent"); return true; } catch (e) { return false; } } You can use the following code snippet to detect touch screen devices: function is_touc ...
-
scrollViewSuite示例代码的tapZoom示例中的一些摘录: 首先,触摸结束后启动事物的功能: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch tapCount] == 1) { [self performSelector: @selector(handleSingle ...
-
将一个不可见的按钮放置在文本区域上,方法如下: UIButton* button = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; button.frame =CGRectMake(your parameters here); button.showsTouchWhenHighlighted=YES; // handy for debugging [button addTarget:self action:@se ...
-
检测背景水龙头(Detecting background tap)[2023-05-18]
您可以为视图添加手势识别器。 例如 // in viewDidLoad: UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundTapped:)]; tapRecognizer.numberOfTapsRequired = 1; [self.view addGestureRecognizer:tapRecognizer]; ... -
检查- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer的- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer 。 要点按,滑动手势必须失败。 Check the - (void)requireGestureRecognizerToFail:(UIGestureRecognize ...