Jump to content

Search the Community

Showing results for tags 'centering'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 8 results

  1. Don't matter the browser size, I need that the picture ocup 100% the browser height. For this, I just set the img heith in 100vh, and the code works fine. But, I also need this image be horizontal centered in the browser. For this, I've set the text align of my DIV that contain my IMG in center. When the browser width is greater than the img width, it works fine. But, if the browser width is less than the img width, the img go left aligned. I really need that img be centered in the browser size all the time, don't matter the conditions. I just know that I can do it replacing the img for background-image and set the background-position in center. But, if I did it, Google will not index my images and it results in a big trouble for me. <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <link type="text/css" rel="stylesheet" href="code/css/test.css"> </head> <body> <div> <img src="image.jpg"> </div> </body> </html> * { margin: 0; padding: 0 } div { background-color: red; text-align: center; } img { height: 100vh; } (The picture I'm working is 1680px x 945px) At the image below I'm showing the correct horizontal align for this picture. Centered: https://uploaddeimagens.com.br/imagens/certo-jpg-feef13d2-44d2-407b-8b1b-f334107cb371 And... At this another image, I'm showing the error it ocurrs. The picture is left aligned and crop only the right side of the picture: https://uploaddeimagens.com.br/imagens/errado-jpg-746c72b8-36d2-4942-9895-0cfb43abd77d What I need is... When the browser width is less than the img width, the picture still be centered in the browser, resulting that the image would be cropped both sides, ledt and right sides, and it will result in this specifically image, the church in background will be centered in the browser all the time. It was a simple example that what I need. Is there any way for center this image like I need using only CSS? I will be very grateful to anyone who can help me with this problem. Thanks. Greetings from Brazil.
  2. Good evening. I'm creating a 3-column layout, in which the left and right columns should have their widths set to 300px, and the middle column should fit in the rest left over. Regarding the layout everything is OK, exactly as I need it. However, within the central DIV, I put an IMG, which I want to always occupy 100% of the height of this DIV and that it is centered horizontally, independently of the width of the DIV in which this IMG is contained is larger or smaller width than the width of the IMG itself. Relative to occupying 100% of the height everything is OK, no matter how I resize the browser window it is self-adjusting as desired. However, it is not getting horizontally centered, as is the goal. It is always left-aligned, except when the width of the DIV is greater than the width of the IMG, so the IMG is thus perfectly centered inside the container DIV. However, when the width of the DIV is smaller than the width of the IMG, the IMG is left-aligned, cutting portions of the image only on its right side, not getting centered as expected. I'm testing on a desktop with 1920x1080 resolution and the image I'm using at IMG is 1680x945px. Here are the HTML and CSS codes: !doctype html> <html lang="pt-br"> <head> <link type="text/css" rel="stylesheet" href="code/css/estudo.css"> </head> <body> <div id="main"> <div id="viewport_left" class="viewports"> </div> <div id="viewport_center" class="viewports"> <img id="imagem_teste" src="imagem_teste_01.jpg"> </div> <div id="viewport_right"> </div> </div> <div id="footer"> </div> </body> </html> * { margin: 0; padding: 0; text-align: center; overflow: hidden; } #main { width: 100%; margin: 0; } #viewport_left { min-height: calc(100vh - 25px); margin-bottom: 25px; width: 324px; background-color: #333333; position: fixed; left: 0; top: 0; } #viewport_center { min-height: calc(100vh - 25px); width: calc(100vw - 650px); margin-bottom: 25px; border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF; background-color: red; position: absolute; left: 50%; top: 50%; margin-left: calc(((100vw - 648px) / 2)* -1); margin-top: calc((100vh / 2)* -1); display: table; overflow: hidden; } #imagem_teste { max-height: calc(100vh - 25px); position: absolute; width: auto; height: auto; } #viewport_right { min-height: calc(100vh - 25px); margin-bottom: 25px; width: 324px; background-color: #333333; position: fixed; right: 0; top: 0; } #footer { position: fixed; bottom: 0; left: 0; height: 24px; width: 100%; background-color: #333333; border-top: 1px solid #FFFFFF; text-align: center; font-family: Verdana, Geneva, sans-serif; font-size: 12px; color: #FFFFFF; } Does anyone know how can I fix this problem? Thank you in advance for any help and cooperation. Thank you, Evair Peterson.
  3. I'm new to forum, a neophyte when it comes to HTML and CSS, brought up via Frontpage with all its "foibles". Trying desperately to fix my website and make it all HTML5 and CSS3 valid. I'm going crazy trying to insert images in text (floating right or left) with a caption underneath. In the old days of tables I could do this in 5 seconds. So far everything I've tried just doesn't work. To begin clean I created the most simple of test programs with one photo, one caption, no overhead crap, no style sheets. Here is the code: <figure> <img alt="" src="literature/worktales/images/brunswickMineShotcrete.jpg" style="float:right"/> <figcaption>Shotcrete</figcaption> </figure> The results are here: www.raiderracing.com/test.htm. I did lots of research on this site and others and tried different scenarios and none worked. I'm using Expressions Web 4 for editing, and latest MS Edge or Google Chrome for browsers. I tried this on the W3C "Tryit" page and floating the figure left or right leaves the caption where it is. Using just <img alt="" src="literature/worktales/images/brunswickMineShotcrete.jpg" style="float:right"/>shotcrete achieves the same thing with 4 fewer commands. So, bottom line: how do I float photos left and right in text, and put a caption underneath?
  4. Hi everyone! I am trying to vertically center divs inside another div, using: position: relative;vertical-align: middle; But it's not working! Does anyone know why? On this page: http://www.jasonwangart.com/p/about-web.html , I am trying to make the dividers - the vertical black lines - be vertically centered within the parent div. You can see my code here: <!doctype html> <style> .jw-1-about-centre-align { width: 300%; border: 0px solid red; font-size: 16px; background-color: rgba(255,255,255,0.0); text-align: center; } .jw-2-about-pad { vertical-align: top; display: inline-block; min-width: 60px; padding: 0px 0px 0px 0px; border: solid rgba(0,0,0,0.2); border-width: 0px 1px 0px 1px; border-radius: 15px 15px 15px 15px / 30px 30px 30px 30px; margin: 0px auto 0px auto; text-align: left; font-size: 16px; background-color: rgba(255,255,255,0.3); } .jw-3-about-column { vertical-align: top; display: inline-block; border: 0px solid orange; width: 300px; height: 100%; margin: 10px 15px 10px 15px; } .jw-3-about-divider { display: inline-block; border: 0px solid green; width: 1px; height: 300px; margin: 0px 0px 0px 0px; background-color: rgba(0,0,0,0.5); position: relative; vertical-align: middle; } .jw-4-about-text-header { width: 100%; border: 0px solid green; margin: 20px auto 20px auto; font-size: 1.2em; font-weight: bold; font-style: italic; } .jw-4-about-text-body { width: 100%; border: 0px solid yellow; margin: 20px auto 20px auto; }</style> <div class="jw-1-about-centre-align"> <div class="jw-2-about-pad"> <div class="jw-3-about-column"> <div class="jw-4-about-text-header"> About me: </div> <!-- JUST SOME CODE FOR THE TEXT - OMITTED FOR SIMPLICITY --> </div> <div class="jw-3-about-divider"> </div> <div class="jw-3-about-column"> <div class="jw-4-about-text-header"> <b>Contact me:</b> </div> <!-- JUST SOME CODE FOR THE FORM - OMITTED FOR SIMPLICITY --> </div> <div class="jw-3-about-divider"> </div> <div class="jw-3-about-column"> <div class="jw-4-about-text-header"> <b>Email updates:</b> </div> <!-- JUST SOME CODE FOR THE FORM - OMITTED FOR SIMPLICITY --> </div> </div> </div> </!doctype>
  5. Hi All, Much has been learnt and heaps of progress has been made since my last post, Coming across something weird now however. If you inspect my test site here http://mrt.guardian1.com.au:57005/test2/index_template.php you will see that in the footer I cannot seem to get the 3 divs to allign. Can someone please point me in the right direction on what css to apply. Specifically this is the HTML for the footer <div data-role="footer" class="footer" data-id="footer" data-position="fixed"> <div> <div> <button onclick="history.go(0)" class="medbtn ui-btn ui-corner-all ui-icon-refresh ui-btn-icon-left" data-role="button" data-icon="refresh" >Refresh</button> <button id="gps_address" class="medbtn ui-btn ui-corner-all ui-icon-navigation ui-btn-icon-left" data-role="button" data-icon="refresh" >Current Location ?</button> </div> <div class="center"> <label>YCH-882</label> </div> <div class="time right"> <span id="time" /><script src="custom/time.js"></script> </div> </div></div> and this is the css .footer{ display: block; }.time{ margin-right:15px; margin-top:8px; }.right{ text-align: right;}.center{ text-align: center;}
  6. Hi guys I have a navigation bar where the code for the position isposition:absolute; left:350px; top:400px;On my computer it looks fine and where I wanted it to be. But on my friends computer it's skewed all the way to the right. So what am I doing wrong? I'm fairly new to CSS and only learned through some online reading so sorry for the beginners question :/ @font-face { font-family: 'Limelight'; src:url(../fonts/Limelight.eot); src:local(Limelight), url('../fonts/Limelight.ttf') format('opentype');} body { background:url(../images/bg.png); margin: 0; padding:0;}#logo { background:url(../images/header.png) no-repeat; background-position:50% 0%; width:100%; display:table; }#content { width: 900px; margin: 450px auto 0; background: white; border: solid 1px #CCC; padding: 20px 20px 0px 20px;}#header { position:absolute; left:350px; top:400px; list-style:none;}#header li { display:inline; padding:0px 32px 0px 0px;}#header ul li a { font-family:'Limelight'; color:#FFF; font-size:30px; text-decoration:none;}#header li a:visited { display:inline; font-family:'Limelight'; color:#FFF; font-size:30px;}
  7. James_Parsons

    Centering

    I know the tag is deprecated but is there an easy way to center items. for example take this code and "de-deprecate" <!DOCTYPE html><html><body> <center><p>Hello</p></center></body></html>
  8. jegranet

    Site not centreing

    My site is not centreing, despite using, #site { width: 950px; background:#848484; margin:0 auto; }; see: www.templatetest.co.uk Can anyone see what the problem might be. I have never had this problem before and wonder if it is a conflict with something else in the css file.Jean chilli.css
×