首页 \ 问答 \ 并排
元素(Align
elements side by side)

并排
元素(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.

相关问答

更多
  • 三个简单的猜测: 1)VB应用程序真的可能在引擎盖下调用“DialogBox”API(例如DialogBoxParam,CreateDialogIndirect等)吗? 2)您正在运行64位操作系统并挂接64位user32.dll。 因此,32位应用程序并未陷入困境。 在c:\ windows \ syswow64中有一个32位的user32.dll副本 3)您不挂钩应用程序正在使用的user32.dll。 许多较旧的应用程序可能会获得一些DLL重定向。 从命令提示符处,从c:\ windows \ win ...
  • 窗口创建后,某些控件样式不能更改。 ES_AUTOHSCROLL样式(基本上控制文字换行)就是其中之一。 这是由编辑控制风格的MSDN部分(有些间接地)陈述的。 您可以使用SetWindowLong()设置这些位,但控件将忽略它们或行为不正常。 干净地做到这一点的唯一方法是使用所需的样式重新创建编辑控件。 这实际上是记事本在切换“Word Wrap”设置时执行的操作。 Some control styles cannot be changed after window creation. The ES_AU ...
  • 您在webView上应用QWebSettings,但它们有效地存储在webView->page() 。 所以当你做webView->setPage(newWeb); 您恢复默认的QWebSettings,包括所需的QWebSettings :: PluginsEnabled。 事实上,您似乎不需要额外的QWebPage,只需将您的QNAM设置为默认值: webView->page()->setNetworkAccessManager(page()->networkAccessManager()); You ...
  • 这不是一个真正的答案,但是因为很多人似乎相信Win32禁止在父项之外的其他线程中创建子项,所以我觉得有必要发表相反的示范。 下面的代码演示了如何在属于不同进程的父级上创建子窗口。 它接受一个窗口句柄值作为命令行参数并在该父窗口上创建一个子窗口。 // t.cpp #include #include #define CLASS_NAME L"fykshfksdafhafgsakr452" static LRESULT CALLBACK WindowProc( ...
  • 几种获取方式: 传递给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() entrypoint, ...
  • LRESULT CALLBACK event(HWND, UINT, WPARAM, LPARAM) { return 0; } 这是一个基本上被破坏的窗口过程。 为你自己处理的消息调用DefWindowProc() 不是可选的。 现在它不会创建窗口,因为您为WM_NCCREATE消息返回FALSE。 它应该返回TRUE以允许创建窗口。 你也不会从GetLastError()得到错误代码,就操作系统而言,你有意拒绝让窗口创建。 固定: LRESULT CALLBACK event(HWND hwn ...
  • 问题是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 wide ...
  • 我设法弄清楚到底发生了什么,以及如何解决问题。 我没有使用[STAThread]属性指定我的主入口点,因此它默认为MTA。 这意味着当我调用VB6代码时,它创建了一个RPC回调线程,并没有编写对UI执行的主线程的调用。 Peter Mortensen写了一个很好的解释 : STA模型用于非线程安全的COM对象。 这意味着他们不会处理自己的同步。 这种情况的一个常见用途是UI组件。 因此,如果另一个线程需要与对象交互(例如按下表单中的按钮),则将消息编组到STA线程上。 窗体形式的消息泵送系统就是一个例子。 ...
  • 使用CreateWindow/Ex()而不是CreateDialog() / DialogBox()没有任何问题。 运行自己的模态消息循环没有任何问题,只要你正确实现它。 例如,请注意这个警告: 模态,第3部分:WM_QUIT消息 关于模态的另一个重要的事情是WM_QUIT消息总是打破模态循环。 在你自己的模态循环中记住这一点! 如果您调用PeekMessage函数或GetMessage函数并获取WM_QUIT消息,则不仅必须退出模态循环, 还必须重新生成WM_QUIT消息(通过PostQuitMessag ...
  • 首先,您的错误处理是错误的。 文档告诉您仅在CreateWindow失败时才调用GetLastError 。 并且返回值为NULL表示CreateWindow失败。 在调用GetLastError之前,必须检查CreateWindow的返回值。 请确保仔细阅读文档 。 你在调用RegisterClass犯了同样的错误。 在你的辩护中,这是新手Win32程序员最常犯的错误。 错误代码1813是ERROR_RESOURCE_TYPE_NOT_FOUND 。 文件说: 无法在映像文件中找到指定的资源类型。 同样, ...

相关文章

更多

最新问答

更多
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • Java中的不可变类(Immutable class in Java)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • EXCEL VBA 基础教程下载
  • RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
  • 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)
  • JAVA环境变量的设置和对path , classpth ,java_home设置作用和目的?
  • mysql 关于分组查询、时间条件查询
  • 如何使用PowerShell匹配运算符(How to use the PowerShell match operator)
  • Effective C ++,第三版:重载const函数(Effective C++, Third edition: Overloading const function)
  • 如何用DELPHI动态建立MYSQL的数据库和表? 请示出源代码。谢谢!
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 使用前端框架带来哪些好处,相对于使用jquery
  • Ruby将字符串($ 100.99)转换为float或BigDecimal(Ruby convert string ($100.99) to float or BigDecimal)
  • 高考完可以去做些什么?注意什么?
  • 如何声明放在main之后的类模板?(How do I declare a class template that is placed after the main?)
  • 如何使用XSLT基于兄弟姐妹对元素进行分组(How to group elements based on their siblings using XSLT)
  • 在wordpress中的所有页面的标志(Logo in all pages in wordpress)
  • R:使用rollapply对列组进行求和的问题(R: Problems using rollapply to sum groups of columns)
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • python中使用sys模块中sys.exit()好像不能退出?
  • 将Int拆分为3个字节并返回C语言(Splitting an Int to 3 bytes and back in C)
  • 在SD / MMC中启用DDR会导致问题吗?(Enabling DDR in SD/MMC causes problems? CMD 11 gives a response but the voltage switch wont complete)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 如何将字符串转换为Elixir中的函数(how to convert a string to a function in Elixir)