?
Solved

Urgent Help with HTML CSS Positioning

Posted on 2016-11-18
9
Medium Priority
?
89 Views
Last Modified: 2016-11-18
Hi all,

I am trying to get

The text and download buttons to be in the centre of this div, height and width.

My code just don't seem to work I have tried everything. any help is highly appreciated, Thanks.

Here is the design

Screen-Shot-2016-11-18-at-13.52.05.png
Here is My code

HTML

<div id="clear"></div>
       
          <div id="downloadsection">
          <div id="downloadtext">
          <h1>Download the app Today!</h1>
          <div class="button3">TRY APP</div>
          <div class="button4">BUY APP</div>
          </div>
          </div>

Open in new window


CSS

/* START DOWNLOAD SECTION */

#downloadsection {
    background-color: #0C2633;
    height: 400px; 
    width: 100%;
}

#downloadsection h1{
    margin: top: 50px;  
    text-align: center;
    margin-bottom: 20px;
    color: #1da6c4; 
    font-size: 35px; 
    text-transform: uppercase;
    
}

#downloadtext {
      
    width: 52%;
    background-color: pink;
    display: block; 
    margin: 0 auto; 
    

}

Open in new window


I really need to get this sorted asap.

Thanks Again.
0
Comment
Question by:Mike Moore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 10

Expert Comment

by:Paweł
ID: 41892852
here you go

http://codepen.io/chooch/pen/vygBJP

<div id="clear"></div>

<div id="downloadsection">
  <div id="downloadtext">
    <h1>Download the app Today!</h1>
    <span class="button">TRY APP</span>
    <span class="button">BUY APP</span>
  </div>
</div>


/* START DOWNLOAD SECTION */

#downloadsection {
    background-color: #0C2633;
    height: 400px;
    width: 100%;
    display: flex;
  flex-direction: column;
  justify-content: center;
}

#downloadsection h1{
    margin: top: 50px;  
    text-align: center;
    margin-bottom: 20px;
    color: #1da6c4;
    font-size: 35px;
    text-transform: uppercase;
   
}

#downloadtext {
  margin:50% auto;
     text-align: center;
    width: 52%;
    background-color: pink;
    display: block;
    margin: 0 auto;
}
   


just made you two link buttons into inline elements that means they'll just render next to each other as long as they have space, then i just centered everything in your containing div. an volia
0
 

Author Comment

by:Mike Moore
ID: 41892857
Hi, what did you change? sorry I'm new to web dev.

Thanks
0
 
LVL 10

Accepted Solution

by:
Paweł earned 2000 total points
ID: 41892863
no worries, takes a bit to get a handle on it. i made the outer container the box that contains the pink content one into a flex box and set it's properties


  display: flex;
  flex-direction: column;
  justify-content: center;

actually rather than me give you a second hand explanation, check out the following
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Closing Comment

by:Mike Moore
ID: 41892875
Thanks a bunch.

I am in my 1st month at uni so this really helps.

Regards,
Mike
0
 

Author Comment

by:Mike Moore
ID: 41892884
just one more thing, sorry.

I can't get the text to align inside the buttons also same sort of problem.

any idea?

Screen-Shot-2016-11-18-at-14.22.33.png
Thanks
0
 
LVL 10

Expert Comment

by:Paweł
ID: 41892893
so the buttons are inside span tags now, which are inline elements, what i would do is give them a padding something like

.button{
  background-color:red;
  padding: 2px 10px;
}

that or give them a static width and change the display of the element to inline-block

.button{
  background-color:red;
  width:200px;
  display:inline-block;
  text-align:center;
}

the text-align:center is probably not needed,

take a look at the codepen
0
 
LVL 10

Expert Comment

by:Paweł
ID: 41892901
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41892917
Flex has cross browser limitations. Another option is to use display: table like so
<style type="text/css">
#downloadsection {
  background-color: #0C2633;
  height: 400px; 
  width: 100%;
  display: table;
}
#downloadsection h1 {
  margin: top: 50px;  
  text-align: center;
  margin-bottom: 20px;
  color: #1da6c4; 
  font-size: 35px; 
  text-transform: uppercase;
}
#downloadtext {
  width: 100%;
  text-align: center;
  display: table-cell;
  height: 100%;
  vertical-align: middle;
}
.button {
  border-radius: 5px;
  padding: 5px 25px;
  color: white;
  font-size: 25px;
  margin-left: 15px;
}
.button3 {
  background: #1fb18a;
}
.button4 {
  background: #1ea6c4;
}
</style>

Open in new window

HTML
    <div id="clear"></div>
      <div id="downloadsection">
        <div id="downloadtext">
          <h1>Download the app Today!</h1>
          <a class="button button3">TRY APP</a>
          <a class="button button4">BUY APP</a>
      </div>
    </div>

Open in new window


Working sample here
0
 

Author Comment

by:Mike Moore
ID: 41892923
Thanks I appreciate all your help. I will give it a shot.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question