center

make thw two consecutive <div> in the center of the container

喜你入骨 提交于 2019-12-12 04:39:01
问题 I have <div id="container"> <div id="div2">Title</div> <div id="div3">text text</div> </div> where #container { height:500px; width:100%; text-align: center; } #div2, #div3 { width: 50%; } is there anyway to make the both #div2 and div3 together at the center of the #container (horizontally and vertically) with their height being variable? 回答1: This is a hard question to answer because in all reality we have no idea what your width is going to even come close to looking like once you place

Center List in side a div

点点圈 提交于 2019-12-12 03:42:47
问题 I'm trying to center my list with images inside a div. This is what I'm getting (icons way too small and not centered). this is the css ive got and the html <div id="social"> <ul> <li><img src="img/footertwitter.png" alt="placeholder+image"></li> <li><img src="img/footerfacebook.png" alt="placeholder+image"></li> <li><img src="img/footeremail.png" alt="placeholder+image"></li> </ul> </div> #social { margin: 0 auto; text-align: center; width: 90%; max-width: 1140px; position: relative; }

Needing to vertical center images inside div but answers found here aren't working

耗尽温柔 提交于 2019-12-12 02:28:18
问题 I've done this: #parent { display:table-cell; vertical-align:middle; } and this img { vertical-align: middle; } #parent { height:200px; line-height: 200px; } This is the css of the parent div #parent{ display: table-cell; vertical-align: middle; position:relative; float:left; margin: 5px 5px 5px 5px; width:200px; height:200px; background-color:#e0ffff; border-style:solid;border-width:5px; } I do not know what the dimensions of the images will be. I only know they will not be greater than

Center watermark text on image when unknown size of text

故事扮演 提交于 2019-12-12 01:57:37
问题 I'm trying to create an image with a watermark text in it and I want it to be central on the image. The text I want to watermark can be anywhere from 5 characters to 15 characters, therefore I cannot put a final size for the text to fit every image. This is the code I use to create the watermarked image function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) { list($width, $height) = getimagesize($SourceFile); $image_p = imagecreatetruecolor($width, $height); $image =

Center a div that contains a contact form

可紊 提交于 2019-12-12 01:26:38
问题 How do I center a contact form which is inside a div. I have tried margin:0 auto; and it didn't work. <div id="new_div_3"> <form class="contact_form" action="#" method="post" name="contact_form"> <ul> <li> <h2>Contact Us</h2> <span class="required_notification">* Denotes Required Field</span> </li> <li> <label for="name">Name:</label> <input type="text" placeholder="John Doe" required /> </li> <li> <label for="email">Email:</label> <input type="email" name="email" placeholder="john_doe

How do I position a div 'x' pixels from the center of a page?

守給你的承諾、 提交于 2019-12-12 00:55:41
问题 I want to position a <div> a given number of pixels relative to the center of a page. How can this be done? 回答1: You can use $(window).width() / 2 to get the horizontal center... like: $('.myDiv').css({left: ($(window).width() / 2) - 50}) You'll get the div 50px left of the center 来源: https://stackoverflow.com/questions/11905699/how-do-i-position-a-div-x-pixels-from-the-center-of-a-page

css: image cropped by block. drawing border around the visible area. Untrivial question

人走茶凉 提交于 2019-12-11 23:48:51
问题 suppose we have a visible area 300 x 200 pixels suppose we have an image of any size. It can be bigger or smaller than the visible area. Question: 1.center the image vertically and horizontally inside the visible area. Crop overflowing parts of the image 1a. vertical centering is unimportant and can be omitted 2.draw the border around the visible part of the image. Note that the border can match either the outer div border or image border 2a. clarification : I want to find the way of (for

center submenu under variable width parent

只谈情不闲聊 提交于 2019-12-11 21:04:03
问题 sorry if this has been asked before, I've looked and have tried several options but I can't seem to get this to work. I want to center my submenu. Each parent item has variable widths, and the submenu items also have variable widths.. This is my code: .menu-wrap ul li{margin:0;padding:0;display:inline-block} .menu-wrap ul li>a{font-size:16px;color:rgba(0,0,0,.6);display:block} .menu-wrap ul li>ul{position:absolute;float:left;left:0;right:auto;top:90px;width:auto;padding:10px 0;background:#fff

CSS vertically align div while maintaining aspect ratio

怎甘沉沦 提交于 2019-12-11 18:57:36
问题 I used the JsFiddle at jsfiddle.net/5tzk3/10. I changed it to display the div as square shaped dialog (both horizontally and vertically centered). The result is at jsfiddle.net/5tzk3/548. As you see, centering horizontally was easy, but I could not get it centered vertically. Anyone who knows how to do that with pure CSS? Edited code below: <div class="blind"> <div class="wrapper"> <div class="main"> I'm your div with an aspect-ratio of 1:1! </div> </div> </div> html, body, .blind { height:

Win API Aligning text on a button

元气小坏坏 提交于 2019-12-11 18:31:30
问题 Is there a way to center align the text inside a button both horizontally and vertically? case WM_DRAWITEM: { LPDRAWITEMSTRUCT Item; Item = (LPDRAWITEMSTRUCT)lParam; SelectObject(Item->hDC, CreateFont(17, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial Black")); FillRect(Item->hDC, &Item->rcItem, CreateSolidBrush(0xE0E0E0) ); SetBkMode(Item->hDC, 0xE0E0E0); SetTextColor(Item->hDC, RGB(255,255,255)); int len; len =