在本文中,我们将带你了解cssdisplay和vertical-align属性在这篇文章中,我们将为您详细介绍cssdisplay和vertical-align属性的方方面面,并解答css中displ
在本文中,我们将带你了解css display和vertical-align 属性在这篇文章中,我们将为您详细介绍css display和vertical-align 属性的方方面面,并解答css中display属性和hover属性常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant的实例源码、CSS table td vertical-align text-top、CSS vertical-align 居中_html/css_WEB-ITnose、CSS vertical-align 属性。
本文目录一览:- css display和vertical-align 属性(css中display属性和hover属性)
- com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant的实例源码
- CSS table td vertical-align text-top
- CSS vertical-align 居中_html/css_WEB-ITnose
- CSS vertical-align 属性
css display和vertical-align 属性(css中display属性和hover属性)
display
定义和用法
display 属性规定元素应该生成的框的类型。
1 <html> 2 <head> 3 <style type="text/css"> 4 p {display: inline} 5 div {display: none} 6 </style> 7 </head> 8 9 <body> 10 <p>本例中的样式表把段落元素设置为内联元素。</p> 11 12 <p>而 div 元素不会显示出来!</p> 13 14 <div>div 元素的内容不会显示出来!</div> 15 </body> 16 </html>
vertical-align
定义和用法
vertical-align 属性设置元素的垂直对齐方式。
1 <html> 2 3 <head> 4 <style type="text/css"> 5 img.top {vertical-align:text-top} 6 img.bottom {vertical-align:text-bottom} 7 </style> 8 </head> 9 10 <body> 11 12 <p> 13 这是一幅<img class="top" border="0" src="/i/eg_cute.gif" />位于段落中的图像。 14 </p> 15 16 <p> 17 这是一幅<img class="bottom" border="0" src="/i/eg_cute.gif" />位于段落中的图像。 18 </p> 19 20 </body> 21 22 </html>
com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant的实例源码
private SafeHtml getimageHtml(ImageResource res,VerticalAlignmentConstant valign) { AbstractimagePrototype proto = AbstractimagePrototype.create(res); SafeHtml image = SafeHtmlUtils.fromTrustedString(proto.getHTML()); // Create the wrapper based on the vertical alignment. SafeStylesBuilder cssstyles = new SafeStylesBuilder().appendTrustedString(direction + ":0px;"); if (HasverticalAlignment.ALIGN_TOP == valign) { return templates.imageWrapperTop(cssstyles.toSafeStyles(),image); } else if (HasverticalAlignment.ALIGN_BottOM == valign) { return templates.imageWrapperBottom(cssstyles.toSafeStyles(),image); } else { int halfheight = (int) Math.round(res.getHeight() / 2.0); cssstyles.appendTrustedString("margin-top:-" + halfheight + "px;"); return templates.imageWrapperMiddle(cssstyles.toSafeStyles(),image); } }
public static String decorate(SafeHtml toDecorate,String aId,PublishedCell aCell,VerticalAlignmentConstant valign,SafeHtmlBuilder sb) { SafeStylesBuilder stb = new SafeStylesBuilder(); SafeUri imgSrc = null; if (aCell != null) { stb.append(SafeStylesUtils.fromTrustedString(aCell.toStyledWOBackground())); if (aCell.getIcon() != null) { ImageResource icon = aCell.getIcon(); imgSrc = icon.getSafeUri(); } } String decorId; if (aId != null && !aId.isEmpty()) { decorId = aId; } else { decorId = Document.get().createUniqueId(); } if (imgSrc != null) sb.append(RenderedEditorCell.PaddedCell.INSTANCE.generate(stb.toSafeStyles(),imgSrc,decorId,toDecorate)); else sb.append(RenderedEditorCell.PaddedCell.INSTANCE.generate(stb.toSafeStyles(),toDecorate)); return decorId; }
public ActionIconCellDecorator(ImageResource icon,Cell<C> cell,int spacing,Delegate<C> delegate) { super(icon,cell,valign,spacing); this.delegate = delegate; this.iconHtml = getimageHtml(icon,valign); }
@Override public VerticalAlignmentConstant getVerticalCellAlignment() { return HasverticalAlignment.ALIGN_TOP; }
/** * setCellVerticalAlignment */ public void setCellVerticalAlignment(Widget w,VerticalAlignmentConstant align) { vPanel.setCellVerticalAlignment(w,align); }
@Override public VerticalAlignmentConstant getVerticalCellAlignment() { return HasverticalAlignment.ALIGN_TOP; }
@SuppressWarnings("deprecation") protected void setCellVerticalAlignment(Element td,VerticalAlignmentConstant align) { setCellVerticalAlignment(DOM.asOld(td),align); }
/** * @deprecated Call and override {@link #setCellVerticalAlignment(Element,* VerticalAlignmentConstant)} instead. */ @Deprecated protected void setCellVerticalAlignment(com.google.gwt.user.client.Element td,VerticalAlignmentConstant align) { td.getStyle().setProperty("verticalAlign",align.getVerticalAlignString()); }
/** * Sets the vertical alignment of the specified cell. * * @param row the row of the cell whose alignment is to be set * @param column the column of the cell whose alignment is to be set * @param align the cell's new vertical alignment as specified in * {@link HasverticalAlignment}. * @throws indexoutofboundsexception */ public void setVerticalAlignment(int row,int column,VerticalAlignmentConstant align) { prepareCell(row,column); DOM.setStyleAttribute(getCellElement(bodyElem,row,column),"verticalAlign",align.getVerticalAlignString()); }
/** * Sets the vertical alignment of the given widget within its cell. * * @param w the widget whose vertical alignment is to be set * @param align the widget's vertical alignment,as defined in * {@link HasverticalAlignment}. */ public void setCellVerticalAlignment(Widget w,HasverticalAlignment.VerticalAlignmentConstant align) { Element td = getWidgetTd(w); if (td != null) { setCellVerticalAlignment(td,align); } }
/** * setCellVerticalAlignment * * @param w * @param align */ public void setCellVerticalAlignment(Widget w,align); }
/** * Sets the horizontal and vertical alignment of the specified cell's * contents. * * @param row the row of the cell whose alignment is to be set * @param column the column of the cell whose alignment is to be set * @param hAlign the cell's new horizontal alignment as specified in * {@link HasHorizontalAlignment} * @param vAlign the cell's new vertical alignment as specified in * {@link HasverticalAlignment} * @throws indexoutofboundsexception */ public void setAlignment(int row,HorizontalAlignmentConstant hAlign,VerticalAlignmentConstant vAlign) { setHorizontalAlignment(row,column,hAlign); setVerticalAlignment(row,vAlign); }
/** * Sets the vertical alignment of the specified row. * * @param row the row whose alignment is to be set * @param align the row's new vertical alignment as specified in * {@link HasverticalAlignment} * @throws indexoutofboundsexception */ public void setVerticalAlign(int row,VerticalAlignmentConstant align) { DOM.setStyleAttribute(ensureElement(row),align.getVerticalAlignString()); }
/** * Overloaded version for IsWidget. * * @see #setCellVerticalAlignment(Widget,HasverticalAlignment.VerticalAlignmentConstant) */ public void setCellVerticalAlignment(IsWidget w,VerticalAlignmentConstant align) { this.setCellVerticalAlignment(w.asWidget(),align); }
public VerticalAlignmentConstant getVerticalCellAlignment();
public VerticalAlignmentConstant getVerticalAlignment() { return iVerticalAlignment; }
public void setVerticalAlignment(VerticalAlignmentConstant vertical) { iVerticalAlignment = vertical; }
public VerticalAlignmentConstant getVerticalCellAlignment();
public VerticalAlignmentConstant getVerticalAlignment() { return iVerticalAlignment; }
public void setVerticalAlignment(VerticalAlignmentConstant vertical) { iVerticalAlignment = vertical; }
CSS table td vertical-align text-top
我已经将表td全局设置为vertical-align:middle.
现在我只需要将一个td更改为vertical-align:text-top
问题是,我测试的所有变体都设置了vertical-align:text-top显示为top
(图像中的“xxxx”与“yyyy”不一致)
只有一个变体是作为文本顶部工作,这是所有td的全局风格的变化(我不想要这个,我只需要改变一个td)
看图像
设置为本地风格显示为顶部
local style http://aukro.svecpetr.com/style.png
课堂设置显示为顶部
local style http://aukro.svecpetr.com/class.png
改变全局td对文本顶部有正确的影响
local style http://aukro.svecpetr.com/global-style.png
你可以找到的例子
https://zbozimat.cz/test.php
有人可以帮我吗?
解决方法
display: inline-block; vertical-align: top;
并输入:
display: inline-block; vertical-align: top;
CSS vertical-align 居中_html/css_WEB-ITnose
一般常用的水平居中:
我们可以通过 text-align:center; 来设置
垂直居中:vertical-align:middli; //有时发现设置后没有任何样式的改变。因为 vertical-align 只对 依赖性的元素生效,即 display:inline-block; 有效。
另外还可以通过 : line-height 属性来设置行高 ,控制元素的垂直高度。
CSS vertical-align 属性
定义和用法
vertical-align 属性设置元素的垂直对齐方式。
该属性定义行内元素的基线相对于该元素所在行的基线的垂直对齐。允许指定负长度值和百分比值。这会使元素降低而不是升高。在表单元格中,这个属性会设置单元格框中的单元格内容的对齐方式。
可能的值
更多CSS vertical-align 属性 相关文章请关注PHP中文网!
立即学习“前端免费学习笔记(深入)”;
我们今天的关于css display和vertical-align 属性和css中display属性和hover属性的分享就到这里,谢谢您的阅读,如果想了解更多关于com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant的实例源码、CSS table td vertical-align text-top、CSS vertical-align 居中_html/css_WEB-ITnose、CSS vertical-align 属性的相关信息,可以在本站进行搜索。
本文标签: