Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SOLVED] Layout issue - <Box> won't center #68

Closed
ScottAgirs opened this issue Oct 8, 2018 · 1 comment
Closed

[SOLVED] Layout issue - <Box> won't center #68

ScottAgirs opened this issue Oct 8, 2018 · 1 comment

Comments

@ScottAgirs
Copy link

ScottAgirs commented Oct 8, 2018

Need help centering in a template where the is 600px and centered, tried few ways, nothing works, my best attempt is below:

import React from "react";
import { Box, Email, Item, Span, A, renderEmail } from "react-html-email"; // note we added renderEmail to this import statement

// added our const that holds a string of css (it is worth noting that we can also do inline jss styles as well)
const css = `
body {
  background-color: #244a74;
  text-align: center;
}
@media only screen and (max-device-width: 480px) {
  font-size: 20px !important;
}

.container{
  width:600px;
  margin:0 auto;
  background: rgba(255,255,255,0.9)
}

`.trim();

const TeacherStudioCreatedTemplate = () => {
  const textDefaults = {
    fontFamily: "Verdana",
    fontSize: 42,
    fontWeight: "bold",
    color: "orange"
  };

  return (
    <Email title="Title" headCSS={css}>
      <Box className="container">
          <Item>
            <Span {...textDefaults}>
              text
            </Span>
        </Item>
      </Box>
    </Email>
  );
};

@ScottAgirs
Copy link
Author

Hate when this (struggling for hours and then finding solution right after posting) happens.

If anyone else runs into this issue - the trick is to add float: none to the element you want to center, looks like react-html-email have have some defaults that include float (?) not sure ...

@ScottAgirs ScottAgirs changed the title Layout issue - <Box> won't center [SOLVED] Layout issue - <Box> won't center Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant