并排
元素(Align
elements side by side)

我知道这是一个相当简单的问题,但是我无法想像我的生活。 我有两个链接,我已经应用了一个背景图像。 这是现在的样子(对于阴影道歉,只是一个按钮的粗略草图):

在此输入图像描述

但是,我希望这两个按钮并排。 我无法真正弄清楚对齐方式需要做些什么。

这是HTML

<div id="dB"}>
    <a href="http://notareallink.com" title="Download" id="buyButton">Download</a> 
</div>
<div id="gB">
    <a href="#" title="Gallery" onclick="$j('#galleryDiv').toggle('slow');return false;" id="galleryButton">Gallery</a>     
</div>

这是CSS

#buyButton {
    background: url("assets/buy.png") 0 0 no-repeat;
    display:block;
    height:80px;
    width:232px;
     text-indent:-9999px;
}
#buyButton:hover{
width: 232px;
height: 80px;
background-position: -232px 0;
}
#buyButton:active {
width: 232px;
height: 80px;
background-position: -464px 0;
}

#galleryButton {
    background: url("images/galleryButton.png") 0 0 no-repeat;
    display:block;
    height:80px;
    width:230px;
     text-indent:-9999px;
}
#galleryButton:hover{
width: 230px;
height: 80px;
background-position: -230px 0;
}
#galleryButton:active {
width: 230px;
height: 80px;
background-position: -460px 0;
}

I know this is a rather simple question, but I can't figure it out for the life of me. I have two links which I've applied a background image to. Here's what it currently looks like (apologies for the shadow, just a rough sketch of a button):

enter image description here

However, I want those two buttons to be side by side. I can't really figure out what needs to be done with the alignment.

Here's the HTML

<div id="dB"}>
    <a href="http://notareallink.com" title="Download" id="buyButton">Download</a> 
</div>
<div id="gB">
    <a href="#" title="Gallery" onclick="$j('#galleryDiv').toggle('slow');return false;" id="galleryButton">Gallery</a>     
</div>

Here's the CSS

#buyButton {
    background: url("assets/buy.png") 0 0 no-repeat;
    display:block;
    height:80px;
    width:232px;
     text-indent:-9999px;
}
#buyButton:hover{
width: 232px;
height: 80px;
background-position: -232px 0;
}
#buyButton:active {
width: 232px;
height: 80px;
background-position: -464px 0;
}

#galleryButton {
    background: url("images/galleryButton.png") 0 0 no-repeat;
    display:block;
    height:80px;
    width:230px;
     text-indent:-9999px;
}
#galleryButton:hover{
width: 230px;
height: 80px;
background-position: -230px 0;
}
#galleryButton:active {
width: 230px;
height: 80px;
background-position: -460px 0;
}

原文:https://stackoverflow.com/questions/4938716
2023-03-09 07:03

满意答案

窗口创建后,某些控件样式不能更改。 ES_AUTOHSCROLL样式(基本上控制文字换行)就是其中之一。 这是由编辑控制风格的MSDN部分(有些间接地)陈述的。 您可以使用SetWindowLong()设置这些位,但控件将忽略它们或行为不正常。

干净地做到这一点的唯一方法是使用所需的样式重新创建编辑控件。 这实际上是记事本在切换“Word Wrap”设置时执行的操作。


Some control styles cannot be changed after window creation. The ES_AUTOHSCROLL style (which essentially controls word wrapping) is one of them; this is stated (somewhat indirectly) by the MSDN section on Edit Control Styles. You can set the bits using SetWindowLong(), but the control will either ignore them or behave erratically.

The only way to do this cleanly is to recreate the edit control using the required styles. This is actually what Notepad does when you toggle the "Word Wrap" setting.

相关问答

更多

如何在不使用CreateWindow(Ex)的情况下创建窗口(HWND)?(How can I create a window (HWND) without using CreateWindow(Ex)?)

三个简单的猜测: 1)VB应用程序真的可能在引擎盖下调用“DialogBox”API(例如DialogBoxParam,CreateDialogIndirect等)吗? 2)您正在运行64位操作系统并挂接64位user32.dll。 因此,32位应用程序并未陷入困境。 在c:\ windows \ syswow64中有一个32位的user32.dll副本 3)您不挂钩应用程序正在使用的user32.dll。 许多较旧的应用程序可能会获得一些DLL重定向。 从命令提示符处,从c:\ windows ...

WS_VSCROLL,CreateWindow风格的作品,SetWindowLong不(WS_VSCROLL, CreateWindow style works, SetWindowLong doesnt)

窗口创建后,某些控件样式不能更改。 ES_AUTOHSCROLL样式(基本上控制文字换行)就是其中之一。 这是由编辑控制风格的MSDN部分(有些间接地)陈述的。 您可以使用SetWindowLong()设置这些位,但控件将忽略它们或行为不正常。 干净地做到这一点的唯一方法是使用所需的样式重新创建编辑控件。 这实际上是记事本在切换“Word Wrap”设置时执行的操作。 Some control styles cannot be changed after window creation. The ...

createWindow函数不加载flashplayer内容(createWindow function doesn't load flashplayer content)

您在webView上应用QWebSettings,但它们有效地存储在webView->page() 。 所以当你做webView->setPage(newWeb); 您恢复默认的QWebSettings,包括所需的QWebSettings :: PluginsEnabled。 事实上,您似乎不需要额外的QWebPage,只需将您的QNAM设置为默认值: webView->page()->setNetworkAccessManager(page()->networkAccessManager());...

Win32 CreateWindow()调用在子线程中挂起?(Win32 CreateWindow() call hangs in child thread?)

这不是一个真正的答案,但是因为很多人似乎相信Win32禁止在父项之外的其他线程中创建子项,所以我觉得有必要发表相反的示范。 下面的代码演示了如何在属于不同进程的父级上创建子窗口。 它接受一个窗口句柄值作为命令行参数并在该父窗口上创建一个子窗口。 // t.cpp #include <windows.h> #include <stdio.h> #define CLASS_NAME L"fykshfksdafhafgsakr452" static LRESULT CALLBACK Window...

Winapi:插件中的createWindow(Winapi: createWindow in plugin)

几种获取方式: 传递给DllMain()入口点的第一个参数转换为HINSTANCE GetModuleHandle()使用您的DLL名称,转换为HINSTANCE VirtualQuery(),传递函数的地址。 将返回的MEMORY_BASIC_INFORMATION.BASE地址转换为HINSTANCE。 适用于32位和64位版本的Windows。 Several ways to get it: The first argument passed to your DllMain() entryp...

Visual C ++中的CreateWindow()总是返回null(CreateWindow() in Visual C++ always return null)

LRESULT CALLBACK event(HWND, UINT, WPARAM, LPARAM) { return 0; } 这是一个基本上被破坏的窗口过程。 为你自己处理的消息调用DefWindowProc() 不是可选的。 现在它不会创建窗口,因为您为WM_NCCREATE消息返回FALSE。 它应该返回TRUE以允许创建窗口。 你也不会从GetLastError()得到错误代码,就操作系统而言,你有意拒绝让窗口创建。 固定: LRESULT CALLBACK event(HWN...

无法命名我的函数CreateWindow(Can not name my function CreateWindow)

问题是MS使用了#define(我相信根据你是在构建窄字符串还是宽字符串来映射函数)。 你有三个选择。 首先,不要在必须包含相关MS头的文件中使用CreateWindow。 或者,在使用您的函数之前,您可以#undef它(我不建议这样做)。 最后,你可以重命名你的。 The problem is that MS used a #define (I believe to map the function based on whether you are building for narrow or ...

SetWindowLong挂(SetWindowLong Hanging)

我设法弄清楚到底发生了什么,以及如何解决问题。 我没有使用[STAThread]属性指定我的主入口点,因此它默认为MTA。 这意味着当我调用VB6代码时,它创建了一个RPC回调线程,并没有编写对UI执行的主线程的调用。 Peter Mortensen写了一个很好的解释 : STA模型用于非线程安全的COM对象。 这意味着他们不会处理自己的同步。 这种情况的一个常见用途是UI组件。 因此,如果另一个线程需要与对象交互(例如按下表单中的按钮),则将消息编组到STA线程上。 窗体形式的消息泵送系统就是一...

单击菜单命令时使用createwindow()创建窗口(creating a window with createwindow() when clicking a menu command)

使用CreateWindow/Ex()而不是CreateDialog() / DialogBox()没有任何问题。 运行自己的模态消息循环没有任何问题,只要你正确实现它。 例如,请注意这个警告: 模态,第3部分:WM_QUIT消息 关于模态的另一个重要的事情是WM_QUIT消息总是打破模态循环。 在你自己的模态循环中记住这一点! 如果您调用PeekMessage函数或GetMessage函数并获取WM_QUIT消息,则不仅必须退出模态循环, 还必须重新生成WM_QUIT消息(通过PostQuitM...

调用CreateWindow()func WinApi时出现错误1813(Error 1813 when calling CreateWindow() func WinApi)

首先,您的错误处理是错误的。 文档告诉您仅在CreateWindow失败时才调用GetLastError 。 并且返回值为NULL表示CreateWindow失败。 在调用GetLastError之前,必须检查CreateWindow的返回值。 请确保仔细阅读文档 。 你在调用RegisterClass犯了同样的错误。 在你的辩护中,这是新手Win32程序员最常犯的错误。 错误代码1813是ERROR_RESOURCE_TYPE_NOT_FOUND 。 文件说: 无法在映像文件中找到指定的资源类型...

相关文章

更多

Riak, haproxy, and client side applications

转载:http://blog.dloh.org/Riak,-haproxy,-and-client-s ...

gwt 部署在div 中的问题。

按照这片文章(http://developerlife.com/tutorials/?p=231)将我 ...

div 与 iframe页面缩小问题 [JavaScript]

&lt;div width=&quot;20%&quot;&gt;&lt;/div&gt; &lt; ...

如何用正则表达示匹配一个div标签

如何用正则表达示匹配一个div标签

div布局代替frame布局后该如何跳转呢?

进入base.jsp页面后,frame可以分别跳转到top,left,right,bottom之类的子 ...

jquery 效果实现,div失去焦点

我想做一个弹出层.input的失去焦点的时候. [点击层内的link不关闭该层.点击该层外则关闭该层] ...

《DIV.CSS应用视频教程》(DIV+CSS)[压缩包]

中文名: DIV.CSS应用视频教程 英文名: DIV+CSS 资源格式: 压缩包 ...

解决点击没有内容的空白div没有响应click事件的方法

给一个div绑定一个click事件,如果这个div没有内容,在一般浏览器下都没有问题,在IE8下点击的 ...

html中一个div的id是“1:222”的话,怎么利用id给它定义css啊?

如 &lt;style&gt; #1:2{ height:100px; width:100px ...

在列表li里两个浮动div兼容IE6问题

本来一个很简单功能,却难以兼容IE6, &lt;ul class=&quot;ulDiv&quot ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本